git

My personal website source code
Log | Files | Refs | Submodules | README | LICENSE

commit 41696ed78acd02b2c9cbfed7e454d61b8785ab94
parent 3bda886e8dba9451abf2b60553346da24ede34fb
Author: Luís Ferreira <[email protected]>
Date:   Thu, 30 Sep 2021 18:37:24 +0100

github: workflows: add build workflow

Signed-off-by: Luís Ferreira <[email protected]>

Diffstat:
A.github/workflows/build.yml | 141+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 141 insertions(+), 0 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml @@ -0,0 +1,141 @@ +name: build + +on: + pull_request: + branches: + - master + push: + branches: + - master + workflow_dispatch: + +jobs: + hugo: + runs-on: ubuntu-latest + container: klakegg/hugo:0.83.1-ext-alpine-onbuild + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: | + apk add rsync + - name: Build website + run: make full-build + - name: Archive artifact folder + run: tar -cvf public.tar public + - name: Upload Artifacts + uses: actions/upload-artifact@v2 + with: + name: public-build + path: public.tar + if-no-files-found: error + ipfs-car: + runs-on: ubuntu-latest + container: node:16.10.0-alpine3.11 + needs: hugo + steps: + - uses: actions/checkout@v2 + - name: Download the build artifact + uses: actions/download-artifact@v2 + with: + name: public-build + - name: Install dependencies + run: | + apk add make + - name: Extract artifact + run: tar -xvf public.tar + - name: Pack CAR file + run: make npx-ipfs-car-public + - name: Upload CAR Artifact + uses: actions/upload-artifact@v2 + with: + name: public-car-build + path: public.car + - name: Upload CAR CID Artifact + uses: actions/upload-artifact@v2 + with: + name: public-car-cid + path: public.car.cid + ipfs-push: + runs-on: ubuntu-latest + container: alpine:3.14.2 + needs: hugo + if: github.ref == 'refs/heads/master' + steps: + - name: Download the build artifact + uses: actions/download-artifact@v2 + with: + name: public-build + - name: Extract artifact + run: tar -xvf public.tar + - name: Push to IPFS public nodes + uses: aquiladev/[email protected] + with: + path: ./public/ + continue-on-error: true + pinata-pin: + runs-on: ubuntu-latest + container: alpine:3.14.2 + needs: hugo + if: github.ref == 'refs/heads/master' + steps: + - name: Download the build artifact + uses: actions/download-artifact@v2 + with: + name: public-build + - name: Extract artifact + run: tar -xvf public.tar + - name: Remove index blobs + run: rm -rf public/public/ + - name: Install dependencies + run: | + apk add jq + - name: Remove previous pins + run: | + curl -X GET "https://api.pinata.cloud/data/pinList?status=pinned" \ + -H "Authorization: Bearer ${{ secrets.PINATA_JWT }}" \ + | jq -r '.rows[] | select(.metadata.name | contains("lsferreira.net")) | .ipfs_pin_hash' \ + | xargs -r -I {} curl -X DELETE "https://api.pinata.cloud/pinning/unpin/{}" \ + -H "Authorization: Bearer ${{ secrets.PINATA_JWT }}" + - name: Pin on pinata.cloud + uses: aquiladev/[email protected] + with: + path: ./public/ + service: pinata + pinataKey: ${{ secrets.PINATA_KEY }} + pinataSecret: ${{ secrets.PINATA_SECRET }} + pinataPinName: 'lsferreira.net' + web3-storage: + runs-on: ubuntu-latest + container: alpine:3.14.2 + needs: hugo + if: github.ref == 'refs/heads/master' + outputs: + cid: ${{ steps.web3.outputs.cid }} + steps: + - name: Download the build artifact + uses: actions/download-artifact@v2 + with: + name: public-build + - name: Extract artifact + run: tar -xvf public.tar + - name: Add public CAR file + uses: web3-storage/add-to-web3@v1 + id: web3 + with: + web3_token: ${{ secrets.WEB3_STORAGE_TOKEN }} + path_to_add: 'public' + cloudflare-txt: + runs-on: ubuntu-latest + container: alpine:3.14.2 + needs: web3-storage + if: github.ref == 'refs/heads/master' + steps: + - name: Install dependencies + run: | + apk add curl + - name: Update TXT Record + run: | + curl -X PUT "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/dns_records/${{ secrets.CLOUDFLARE_DNS_RECORD_ID }}" \ + -H "Authorization: Bearer ${{ secrets.CLOUDFLARE_TOKEN }}" \ + -H "Content-Type: application/json" \ + --data '{"type":"TXT","name":"_dnslink","content":"dnslink=/ipfs/${{needs.web3-storage.outputs.cid}}","ttl":1}' > /dev/null 2>&1