Skip to content

feat: add workflow to build and deploy to ipfs #3

feat: add workflow to build and deploy to ipfs

feat: add workflow to build and deploy to ipfs #3

Workflow file for this run

name: Build and Deploy to IPFS
# Explicitly declare permissions
permissions:
contents: read
pull-requests: write
statuses: write
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
BUILD_PATH: 'dist'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true # Cancel in progress runs if a new run is started
jobs:
build-and-deploy:
runs-on: ubuntu-latest
outputs:
cid: ${{ steps.deploy.outputs.cid }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Upload static files as artifact
id: upload-artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ env.BUILD_PATH }}
- uses: ipfs/ipfs-deploy-action@v1
name: Deploy to IPFS
id: deploy
with:
path-to-deploy: ${{ env.BUILD_PATH }}
storacha-key: ${{ secrets.STORACHA_KEY }}
storacha-proof: ${{ secrets.STORACHA_PROOF }}
github-token: ${{ github.token }}
- name: Update DNSLink
if: github.ref == 'refs/heads/main' # only update DNSLink for main branch
uses: ipfs/[email protected]
with:
cid: ${{ steps.deploy.outputs.cid }}
dnslink_domain: 'identify.ipfs.network'
cf_record_id: ${{ secrets.CF_DNS_RECORD_ID }}
cf_zone_id: ${{ secrets.CF_DNS_ZONE_ID }}
cf_auth_token: ${{ secrets.CF_DNS_AUTH_TOKEN }}
github_token: ${{ github.token }}
set_github_status: true
gh-pages:
runs-on: 'ubuntu-latest'
needs: build-and-deploy
if: github.ref == 'refs/heads/main' # only deploy to gh-pages for main branch
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: 'github-pages'
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4