|
| 1 | +name: Build and Deploy |
| 2 | + |
| 3 | +# Explicitly declare permissions |
| 4 | +permissions: |
| 5 | + contents: read |
| 6 | + pull-requests: write |
| 7 | + statuses: write |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - main |
| 16 | + |
| 17 | +env: |
| 18 | + BUILD_PATH: 'out' |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 22 | + cancel-in-progress: true # Cancel in progress runs if a new run is started |
| 23 | + |
| 24 | +jobs: |
| 25 | + build-and-deploy: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + outputs: |
| 28 | + cid: ${{ steps.deploy.outputs.cid }} |
| 29 | + steps: |
| 30 | + - name: Checkout code |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Setup Node.js |
| 34 | + uses: actions/setup-node@v4 |
| 35 | + with: |
| 36 | + node-version: '20' |
| 37 | + cache: 'npm' |
| 38 | + |
| 39 | + - name: Install dependencies |
| 40 | + run: npm ci --prefer-offline --no-audit --progress=false |
| 41 | + |
| 42 | + - name: Build project |
| 43 | + run: make website |
| 44 | + |
| 45 | + - name: Upload static files as artifact |
| 46 | + id: upload-artifact |
| 47 | + uses: actions/upload-pages-artifact@v3 |
| 48 | + with: |
| 49 | + path: ${{ env.BUILD_PATH }} |
| 50 | + |
| 51 | + - uses: ipfs/ipfs-deploy-action@v1 |
| 52 | + name: Deploy to IPFS Mirror Providers |
| 53 | + id: deploy |
| 54 | + with: |
| 55 | + path-to-deploy: ${{ env.BUILD_PATH }} |
| 56 | + cluster-url: "/dnsaddr/ipfs-websites.collab.ipfscluster.io" |
| 57 | + cluster-user: ${{ secrets.CLUSTER_USER }} |
| 58 | + cluster-password: ${{ secrets.CLUSTER_PASSWORD }} |
| 59 | + storacha-key: ${{ secrets.STORACHA_KEY }} |
| 60 | + storacha-proof: ${{ secrets.STORACHA_PROOF }} |
| 61 | + #TODO pinata-jwt-token: ${{ secrets.PINATA_JWT_TOKEN }} |
| 62 | + github-token: ${{ github.token }} |
| 63 | + |
| 64 | + # TODO: right now, DNSLink is controlled by Fleek, and we use ipfs/ipfs-deploy-action for PR previews |
| 65 | + #- name: Update DNSLink |
| 66 | + # if: false # TODO github.ref == 'refs/heads/main' # only update DNSLink for main branch |
| 67 | + |
| 68 | + # with: |
| 69 | + # cid: ${{ steps.deploy.outputs.cid }} |
| 70 | + # dnslink_domain: 'specs.ipfs.tech' |
| 71 | + # cf_record_id: ${{ secrets.CF_RECORD_ID }} |
| 72 | + # cf_zone_id: ${{ secrets.CF_ZONE_ID }} |
| 73 | + # cf_auth_token: ${{ secrets.CF_AUTH_TOKEN }} |
| 74 | + # github_token: ${{ github.token }} |
| 75 | + # set_github_status: true |
| 76 | + |
| 77 | + |
| 78 | + gh-pages: |
| 79 | + runs-on: 'ubuntu-latest' |
| 80 | + needs: build-and-deploy |
| 81 | + if: github.ref == 'refs/heads/main' # only deploy to gh-pages for main branch |
| 82 | + permissions: |
| 83 | + pages: write # to deploy to Pages |
| 84 | + id-token: write # to verify the deployment originates from an appropriate source |
| 85 | + environment: |
| 86 | + name: 'github-pages' |
| 87 | + url: ${{ steps.deployment.outputs.page_url }} |
| 88 | + steps: |
| 89 | + - name: Deploy to GitHub Pages |
| 90 | + id: deployment |
| 91 | + uses: actions/deploy-pages@v4 |
0 commit comments