forked from ipfs/ipfs-webui
-
Notifications
You must be signed in to change notification settings - Fork 0
295 lines (253 loc) · 10.7 KB
/
ci.yml
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: ci
on:
workflow_dispatch:
push:
branches:
- main
- feat/fork-use-w3cli
tags:
- '*'
pull_request:
branches:
- main
env:
XDG_CACHE_HOME: ${{ github.workspace }}/.cache
jobs:
build:
name: build
uses: ./.github/workflows/build.yml
# test-unit:
# name: 'test:unit'
# uses: ./.github/workflows/test-unit.yml
publishPreview:
name: publish preview
needs: build
environment: Deploy
runs-on: ubuntu-latest
outputs:
cid: ${{ steps.ipfs.outputs.cid }}
steps:
- uses: actions/checkout@v3.6.0
- name: Setup node
uses: actions/setup-node@v3.6.0
with:
node-version: 18.14.0
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: ipfs-webui_${{ github.sha }}-${{ runner.os }}-build
path: build
- name: Cache bigger downloads
uses: actions/cache@v3.3.1
id: cache
with:
path: ${{ github.workspace }}/.cache
key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }}
${{ runner.os }}-
# pin the built site to ipfs-websites cluster, output the cid as `steps.ipfs.outputs.cid`
# see: https://github.com/ipfs-shipyard/ipfs-github-action
- uses: ipfs/download-ipfs-distribution-action@v1
with:
name: kubo
- uses: ipfs/download-ipfs-distribution-action@v1
with:
name: ipfs-cluster-ctl
- name: Fix DNS resolver
run: |
# fix resolv - DNS provided by Github is unreliable for DNSLik/dnsaddr
sudo sed -i -e 's/nameserver 127.0.0.*/nameserver 1.1.1.1/g' /etc/resolv.conf
- uses: ipfs/start-ipfs-daemon-action@v1
- name: Import build/ to IPFS
id: ipfs
# npx -y kubo@latest add --cid-version 1 -Q -r ./build
run: |
root_cid=$(ipfs add --cid-version 1 -Q -r ./build)
echo "cid=$root_cid" >> $GITHUB_OUTPUT
- run: echo ${{ steps.ipfs.outputs.cid }}
- run: echo ${{ github.ref }}
- name: Create ipfs-webui.car file
run: |
ipfs dag export ${{ steps.ipfs.outputs.cid }} > ipfs-webui_${{ github.sha }}.car
echo "created car file"
# set w3cli principal from https://github.com/web3-storage/w3cli#w3_principal
export W3_PRINCIPAL=$W3_AGENT_PRINCIPAL
export W3_STORE_NAME="ipfs-webui-ci"
npx -y --package=@web3-storage/w3cli@latest -- w3 whoami
echo "got whoami"
echo $W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING | base64 -d > ipfs-webui-ci-space.ucan.proof
echo "converted base64 env var to file"
# npx -y --package=@web3-storage/w3cli@latest -- w3 proof add ipfs-webui-ci-space.ucan.proof
# echo "added proof"
export W3CLI_SPACE_DID=$(npx -y --package=@web3-storage/w3cli@latest -- w3 space add ipfs-webui-ci-space.ucan.proof)
echo "added space"
npx -y --package=@web3-storage/w3cli@latest -- w3 space use $W3CLI_SPACE_DID
echo "using space"
npx -y --package=@web3-storage/w3cli@latest -- w3 up --no-wrap -c ipfs-webui_${{ github.sha }}.car
echo "uploaded car"
env:
W3_AGENT_DID: ${{ secrets.W3_AGENT_DID }}
W3_PRINCIPAL: ${{ secrets.W3_PRINCIPAL }}
W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING: ${{ secrets.W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING }}
# - name: Attach produced build to Github Action
# uses: actions/upload-artifact@v3
# with:
# name: ipfs-webui_${{ github.sha }}.car
# path: ipfs-webui_${{ github.sha }}.car
# if-no-files-found: error
# - name: pin with Fleek
# run: |
# fleek ipfs add
# - name: convert CIDv0 from fleek to CIDv1
# run: |
# ipfs cid base32 QmS4tE76QGjiuH3DU18Ca6oZiZD9U3UzshPFMgnQ7dExCX
# - name: w3cli whoami
# run: npx -y --package=@web3-storage/w3cli@latest -- w3 whoami
# - name: w3cli add ipfs-webui-ci space
# run: |
# cat "${W3CLI_DELEGATION_PROOF_BASE64}" | base64 -d > ./ipfs-webui-ci-space.ucan.proof
# npx -y --package=@web3-storage/w3cli@latest -- w3 space add ./ipfs-webui-ci-space.ucan.proof
# env:
# W3CLI_DELEGATION_PROOF_BASE64: ${{ secrets.W3CLI_DELEGATION_PROOF_BASE64 }}
# - name: use ipfs-webui space
# run: npx -y --package=@web3-storage/w3cli@latest -- w3 space create './ipfs-webui-ci-space.ucan.proof'
# env:
# W3_SPACE_DID: ${{ secrets.W3_SPACE_DID }}
# - name: use ipfs-webui space
# run: npx -y --package=@web3-storage/w3cli@latest -- w3 space use "${W3_SPACE_DID}"
# env:
# W3_SPACE_DID: ${{ secrets.W3_SPACE_DID }}
# - name: use w3cli to upload the car file
# run: |
# npx -y --package=@web3-storage/w3cli@latest -- w3 up -c ipfs-webui_${{ github.sha }}.car
# - name: Pin to estuary.tech
# id: pin-estuary
# continue-on-error: true
# run: |
# curl -X POST https://api.estuary.tech/pinning/pins -d '{ "name": "'$PIN_NAME'", "cid": "'$PIN_CID'" }' -H "Content-Type: application/json" -H "Authorization: Bearer $ESTUARY_API_TOKEN"
# curl -X GET https://api.estuary.tech/pinning/pins -H "Content-Type: application/json" -H "Authorization: Bearer $ESTUARY_API_TOKEN"
# env:
# ESTUARY_API_TOKEN: ${{ secrets.ESTUARY_API_TOKEN }}
# PIN_CID: ${{ steps.ipfs.outputs.cid }}
# PIN_NAME: "ipfs-webui@${{ github.sha }}"
# - name: Pin to ipfs-websites.collab.ipfscluster.io
# id: pin-cluster
# continue-on-error: true
# run: |
# ipfs-cluster-ctl --enc=json \
# --host "${CLUSTER_HOST}" \
# --basic-auth "$CLUSTER_USER:$CLUSTER_PASSWORD" \
# peers ls > cluster-peers-ls
# for maddr in $(jq -r '.ipfs.addresses[]?' cluster-peers-ls); do
# ipfs swarm peering add "$maddr" &
# ipfs swarm connect "$maddr" &
# done
# ipfs-cluster-ctl --enc=json \
# --host "${CLUSTER_HOST}" \
# --basic-auth "${CLUSTER_USER}:${CLUSTER_PASSWORD}" \
# pin add \
# --name "${PIN_NAME}" \
# --replication-min 1 \
# --replication-max 3 \
# --wait \
# $PIN_CID
# env:
# CLUSTER_HOST: "/dnsaddr/ipfs-websites.collab.ipfscluster.io"
# CLUSTER_USER: ${{ secrets.CLUSTER_USER }}
# CLUSTER_PASSWORD: ${{ secrets.CLUSTER_PASSWORD }}
# PIN_CID: ${{ steps.ipfs.outputs.cid }}
# PIN_NAME: "ipfs-webui@${{ github.sha }}"
# - name: Fail job due to pinning failure
# if: steps.pin-estuary.outcome == 'failure' && steps.pin-cluster.outcome == 'failure'
# uses: actions/github-script@v6
# with:
# script: |
# core.setFailed('Pinning did not succeed')
# dev dnslink is updated on each main branch update
# - run: npx dnslink-dnsimple --domain dev.webui.ipfs.io --link /ipfs/${{ steps.ipfs.outputs.cid }}
# if: github.ref == 'refs/heads/main'
# env:
# DNSIMPLE_TOKEN: ${{ secrets.DNSIMPLE_TOKEN }}
# # production dnslink is updated on release (during tag build)
# - run: npx dnslink-dnsimple --domain webui.ipfs.io --link /ipfs/${{ steps.ipfs.outputs.cid }}
# if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
# env:
# DNSIMPLE_TOKEN: ${{ secrets.DNSIMPLE_TOKEN }}
# test-e2e:
# name: 'test:e2e'
# uses: ./.github/workflows/test-e2e.yml
# test-storybook:
# name: 'test:storybook'
# uses: ./.github/workflows/test-storybook.yml
# # separate check for TS
# typecheck:
# name: typecheck
# needs: build
# uses: ./.github/workflows/typecheck.yml
# # separate check for eslint
# eslint:
# name: eslint
# needs: build
# uses: ./.github/workflows/eslint.yml
# automatically commit new tag and changelog updates when a push to main happens.
# This will then trigger
# 1. The 'ci.yml' workflow for the newly committed git tag,
# 2. The 'publish-release-build.yml' workflow
# release:
# name: 'Run semantic release'
# runs-on: ubuntu-latest
# needs: [build, publishPreview, eslint, typecheck, test-e2e, test-unit, test-storybook]
# steps:
# - name: Checkout 🛎️
# uses: actions/checkout@v3.6.0
# with:
# persist-credentials: false
# - name: Cache bigger downloads
# uses: actions/cache@v3.3.1
# id: cache
# with:
# path: ${{ github.workspace }}/.cache
# key: ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }}
# ${{ runner.os }}-
# - name: Cache build dir
# uses: actions/cache@v3.3.1
# id: build-cache
# with:
# path: build
# key: ${{ runner.os }}-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-${{ github.sha }}
# # This is needed for custom-release-notes-generator.js to inject the CID in the release notes
# - name: Write CID to tmp file
# run: |
# echo ${{ needs.publishPreview.outputs.cid }} > .cid
# - name: Setup node
# uses: actions/setup-node@v3.6.0
# with:
# node-version: 18.14.0
# - name: Install dependencies
# run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm
# - name: Download CAR artifact
# uses: actions/download-artifact@v3
# with:
# name: ipfs-webui_${{ github.sha }}.car
# - name: Dry-run semantic release
# if: github.ref != 'refs/heads/main'
# run: |
# git config user.name "ipfs-gui-bot"
# git config user.email "108953096+ipfs-gui-bot@users.noreply.github.com"
# npx semantic-release --ci --dry-run -b ${{ github.ref }}
# env:
# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
# # Update the version (npm version [major|minor|patch])
# - name: Run semantic release
# if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
# run: |
# git config user.name "ipfs-gui-bot"
# git config user.email "108953096+ipfs-gui-bot@users.noreply.github.com"
# npx semantic-release --ci
# env:
# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}