|
| 1 | +name: Build and Deploy to IPFS |
| 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: 'dist' |
| 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 |
| 41 | + |
| 42 | + - name: Build project |
| 43 | + run: npm run build |
| 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 |
| 53 | + id: deploy |
| 54 | + with: |
| 55 | + path-to-deploy: ${{ env.BUILD_PATH }} |
| 56 | + storacha-key: ${{ secrets.STORACHA_KEY }} |
| 57 | + storacha-proof: ${{ secrets.STORACHA_PROOF }} |
| 58 | + github-token: ${{ github.token }} |
| 59 | + |
| 60 | + - name: Update DNSLink |
| 61 | + if: github.ref == 'refs/heads/main' # only update DNSLink for main branch |
| 62 | + |
| 63 | + with: |
| 64 | + cid: ${{ steps.deploy.outputs.cid }} |
| 65 | + dnslink_domain: 'identify.ipfs.network' |
| 66 | + cf_record_id: ${{ secrets.CF_DNS_RECORD_ID }} |
| 67 | + cf_zone_id: ${{ secrets.CF_DNS_ZONE_ID }} |
| 68 | + cf_auth_token: ${{ secrets.CF_DNS_AUTH_TOKEN }} |
| 69 | + github_token: ${{ github.token }} |
| 70 | + set_github_status: true |
| 71 | + |
| 72 | + |
| 73 | + gh-pages: |
| 74 | + runs-on: 'ubuntu-latest' |
| 75 | + needs: build-and-deploy |
| 76 | + if: github.ref == 'refs/heads/main' # only deploy to gh-pages for main branch |
| 77 | + permissions: |
| 78 | + pages: write # to deploy to Pages |
| 79 | + id-token: write # to verify the deployment originates from an appropriate source |
| 80 | + environment: |
| 81 | + name: 'github-pages' |
| 82 | + url: ${{ steps.deployment.outputs.page_url }} |
| 83 | + steps: |
| 84 | + - name: Deploy to GitHub Pages |
| 85 | + id: deployment |
| 86 | + uses: actions/deploy-pages@v4 |
0 commit comments