-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (144 loc) · 4.5 KB
/
build.yml
File metadata and controls
146 lines (144 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: build
on:
pull_request:
branches:
- master
push:
branches:
- master
workflow_dispatch:
jobs:
hugo:
runs-on: ubuntu-latest
container: ljmf00/archlinux
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.MY_GITHUB_PAT }}
submodules: recursive
- name: Install dependencies
run: |
pacman -Syu rsync hugo --noconfirm
sudo -u docker yay -S stagit --noconfirm
- name: Build website
run: make full-build HUGO_ARGS=--minify
- 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.event_name != 'pull_request'
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/ipfs-action@v0.1.6
with:
path: ./public/
continue-on-error: true
pinata-pin:
runs-on: ubuntu-latest
container: alpine:3.14.2
needs: hugo
if: github.event_name != 'pull_request'
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/ public/git/
- 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/ipfs-action@v0.1.6
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.event_name != 'pull_request'
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@77b645f58a5ec593d5ab23666fee1537331b7858
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.event_name != 'pull_request'
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