build.yml (4607B)
1 name: build 2 3 on: 4 pull_request: 5 branches: 6 - master 7 push: 8 branches: 9 - master 10 workflow_dispatch: 11 12 jobs: 13 hugo: 14 runs-on: ubuntu-latest 15 container: ljmf00/archlinux 16 steps: 17 - uses: actions/checkout@v2 18 with: 19 token: ${{ secrets.MY_GITHUB_PAT }} 20 submodules: recursive 21 - name: Install dependencies 22 run: | 23 pacman -Syu rsync hugo --noconfirm 24 sudo -u docker yay -S stagit --noconfirm 25 - name: Build website 26 run: make full-build HUGO_ARGS=--minify 27 - name: Archive artifact folder 28 run: tar -cvf public.tar public 29 - name: Upload Artifacts 30 uses: actions/upload-artifact@v2 31 with: 32 name: public-build 33 path: public.tar 34 if-no-files-found: error 35 ipfs-car: 36 runs-on: ubuntu-latest 37 container: node:16.10.0-alpine3.11 38 needs: hugo 39 steps: 40 - uses: actions/checkout@v2 41 - name: Download the build artifact 42 uses: actions/download-artifact@v2 43 with: 44 name: public-build 45 - name: Install dependencies 46 run: | 47 apk add make 48 - name: Extract artifact 49 run: tar -xvf public.tar 50 - name: Pack CAR file 51 run: make npx-ipfs-car-public 52 - name: Upload CAR Artifact 53 uses: actions/upload-artifact@v2 54 with: 55 name: public-car-build 56 path: public.car 57 - name: Upload CAR CID Artifact 58 uses: actions/upload-artifact@v2 59 with: 60 name: public-car-cid 61 path: public.car.cid 62 ipfs-push: 63 runs-on: ubuntu-latest 64 container: alpine:3.14.2 65 needs: hugo 66 if: github.event_name != 'pull_request' 67 steps: 68 - name: Download the build artifact 69 uses: actions/download-artifact@v2 70 with: 71 name: public-build 72 - name: Extract artifact 73 run: tar -xvf public.tar 74 - name: Push to IPFS public nodes 75 uses: aquiladev/[email protected] 76 with: 77 path: ./public/ 78 continue-on-error: true 79 pinata-pin: 80 runs-on: ubuntu-latest 81 container: alpine:3.14.2 82 needs: hugo 83 if: github.event_name != 'pull_request' 84 steps: 85 - name: Download the build artifact 86 uses: actions/download-artifact@v2 87 with: 88 name: public-build 89 - name: Extract artifact 90 run: tar -xvf public.tar 91 - name: Remove index blobs 92 run: | 93 rm -rf public/public/ public/git/ 94 - name: Install dependencies 95 run: | 96 apk add jq 97 - name: Remove previous pins 98 run: | 99 curl -X GET "https://api.pinata.cloud/data/pinList?status=pinned" \ 100 -H "Authorization: Bearer ${{ secrets.PINATA_JWT }}" \ 101 | jq -r '.rows[] | select(.metadata.name | contains("lsferreira.net")) | .ipfs_pin_hash' \ 102 | xargs -r -I {} curl -X DELETE "https://api.pinata.cloud/pinning/unpin/{}" \ 103 -H "Authorization: Bearer ${{ secrets.PINATA_JWT }}" 104 - name: Pin on pinata.cloud 105 uses: aquiladev/[email protected] 106 with: 107 path: ./public/ 108 service: pinata 109 pinataKey: ${{ secrets.PINATA_KEY }} 110 pinataSecret: ${{ secrets.PINATA_SECRET }} 111 pinataPinName: 'lsferreira.net' 112 web3-storage: 113 runs-on: ubuntu-latest 114 container: alpine:3.14.2 115 needs: hugo 116 if: github.event_name != 'pull_request' 117 outputs: 118 cid: ${{ steps.web3.outputs.cid }} 119 steps: 120 - name: Download the build artifact 121 uses: actions/download-artifact@v2 122 with: 123 name: public-build 124 - name: Extract artifact 125 run: tar -xvf public.tar 126 - name: Add public CAR file 127 uses: web3-storage/add-to-web3@77b645f58a5ec593d5ab23666fee1537331b7858 128 id: web3 129 with: 130 web3_token: ${{ secrets.WEB3_STORAGE_TOKEN }} 131 path_to_add: 'public' 132 cloudflare-txt: 133 runs-on: ubuntu-latest 134 container: alpine:3.14.2 135 needs: web3-storage 136 if: github.event_name != 'pull_request' 137 steps: 138 - name: Install dependencies 139 run: | 140 apk add curl 141 - name: Update TXT Record 142 run: | 143 curl -X PUT "https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/dns_records/${{ secrets.CLOUDFLARE_DNS_RECORD_ID }}" \ 144 -H "Authorization: Bearer ${{ secrets.CLOUDFLARE_TOKEN }}" \ 145 -H "Content-Type: application/json" \ 146 --data '{"type":"TXT","name":"_dnslink","content":"dnslink=/ipfs/${{needs.web3-storage.outputs.cid}}","ttl":1}' > /dev/null 2>&1