Skip to content

ci: refactor into composite action for reusability #52

ci: refactor into composite action for reusability

ci: refactor into composite action for reusability #52

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
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
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 build artifacts
uses: actions/upload-artifact@v4
with:
name: build-output
path: out
- uses: ./.github/actions/deploy-to-ipfs
name: Deploy to IPFS
id: deploy
with:
path-to-deploy: out
storacha-key: ${{ secrets.STORACHA_KEY }}
storacha-proof: ${{ secrets.STORACHA_PROOF }}
pinata-jwt-token: ${{ secrets.PINATA_JWT_TOKEN }}
github-token: ${{ github.token }}
update-dnslink:
runs-on: 'ubuntu-latest'
needs: build-and-deploy
if: github.ref == 'refs/heads/main' # only update DNSLink for main branch
steps:
- name: Update DNSLink
run: |
echo "Updating DNSLink for: ${{ env.DNSLINK_NAME }}"
curl --request PUT \
--header "Authorization: Bearer ${AUTH_TOKEN}" \
--header 'Content-Type: application/json' \
--url "https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${RECORD_ID}" \
--data "{
\"type\": \"TXT\",
\"name\": \"_dnslink.${DNSLINK_NAME}\",
\"content\": \"dnslink=/ipfs/${DNSLINK_CID}\",
\"comment\": \"${{ github.repository }}/${{ github.sha }}\"
}"
env:
DNSLINK_NAME: 'ipns.ipfs.network'
DNSLINK_CID: ${{ needs.build-and-deploy.outputs.cid }}
ZONE_ID: ${{ secrets.CF_IPNS_NETWORK_ZONE_ID }}
RECORD_ID: ${{ secrets.CF_IPNS_NETWORK_RECORD_ID }}
AUTH_TOKEN: ${{ secrets.CF_IPNS_NETWORK_AUTH_TOKEN }}