Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Created April 10, 2022 04:50
Show Gist options
  • Save miguelmota/8a5c9f66330a38b05300f276482f424d to your computer and use it in GitHub Desktop.
Save miguelmota/8a5c9f66330a38b05300f276482f424d to your computer and use it in GitHub Desktop.
Github actions deploy to IPFS and update Cloudflare TXT _dnslink subdomain example
name: deploy
on:
push:
branches:
- master
jobs:
set_environment:
outputs:
env_name: ${{ steps.setenv.outputs.env_name }}
runs-on: ubuntu-latest
steps:
- id: setenv
run: echo "::set-output name=env_name::${GITHUB_REF#refs/heads/}"
build:
name: Deploy
runs-on: ubuntu-latest
needs: set_environment
environment:
name: ${{ needs.set_environment.outputs.env_name }}
defaults:
run:
working-directory: ./src
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 14
registry-url: https://registry.npmjs.org
- name: Install node dependencies
run: npm install
- name: Build the app
run: npm run build
- name: Pin to IPFS on Pinata
id: upload
uses: anantaramdas/[email protected]
with:
pin-name: ${{ github.sha }}
path: './build'
verbose: false
pinata-api-key: ${{ secrets.PINATA_API_KEY }}
pinata-secret-api-key: ${{ secrets.PINATA_SECRET_API_KEY }}
- name: Update CloudFlare DNS with new IPFS hash
env:
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
RECORD_DOMAIN: 'example.com'
RECORD_NAME: '_dnslink'
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }}
uses: textileio/cloudflare-update-dnslink@v2
with:
cid: ${{ steps.upload.outputs.hash }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment