Skip to content

Commit e2fc7c8

Browse files
authored
fix: replace estuary with web3 for pinning (#2182)
1 parent 37b5880 commit e2fc7c8

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

.github/workflows/build.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ jobs:
2323
${{ runner.os }}-${{ hashFiles('package.json', 'package-lock.json') }}
2424
${{ runner.os }}-
2525
26-
- name: Install dependencies
27-
run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm
28-
2926
# Separate cache for build dir, we reuse it in release publish workflow
3027
- name: Cache build output
31-
if: startsWith(github.ref, 'refs/tags/v')
3228
uses: actions/[email protected]
3329
id: build-cache
3430
with:
3531
path: build
36-
key: ${{ runner.os }}-${{ github.sha }}
32+
# Build hash should be based on runner.os, src files, and dependencies used.
33+
key: ${{ runner.os }}-build-${{ hashFiles('package.json', 'package-lock.json', 'public', 'src/**', '*.js', '*.ts') }}
3734
restore-keys: |
38-
${{ runner.os }}-${{ github.sha }}
35+
${{ runner.os }}-build-${{ hashFiles('package.json', 'package-lock.json', 'public', 'src/**', '*.js', '*.ts') }}
36+
37+
- name: Install dependencies
38+
# We only need to install deps if build isn't cached.
39+
if: steps.build-cache.outputs.cache-hit != 'true'
40+
run: npm ci --prefer-offline --no-audit --progress=false --cache ${{ github.workspace }}/.cache/npm
3941

4042
- name: Confirm build works
4143
if: steps.build-cache.outputs.cache-hit != 'true'
@@ -47,6 +49,6 @@ jobs:
4749
- name: Attach produced build to Github Action
4850
uses: actions/upload-artifact@v3
4951
with:
50-
name: ipfs-webui_${{ github.sha }}-build
52+
name: ipfs-webui_${{ github.sha }}-${{ runner.os }}-build
5153
path: build
5254
if-no-files-found: error

.github/workflows/ci.yml

+29-9
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
- name: Download build artifact
4141
uses: actions/download-artifact@v3
4242
with:
43-
name: ipfs-webui_${{ github.sha }}-build
43+
name: ipfs-webui_${{ github.sha }}-${{ runner.os }}-build
4444
path: build
4545

4646
- name: Cache bigger downloads
@@ -85,19 +85,38 @@ jobs:
8585
path: ipfs-webui_${{ github.sha }}.car
8686
if-no-files-found: error
8787

88-
- name: Pin to estuary.tech
89-
id: pin-estuary
88+
# Instructions for this are at https://github.com/ipfs/ipfs-webui/issues/2161#issuecomment-1836835068
89+
- name: Pin to web3.storage with w3cli
90+
id: pin-w3up
91+
# only pin for main commits
92+
if: github.ref == 'refs/heads/main'
9093
continue-on-error: true
9194
run: |
92-
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"
93-
curl -X GET https://api.estuary.tech/pinning/pins -H "Content-Type: application/json" -H "Authorization: Bearer $ESTUARY_API_TOKEN"
95+
# ensure whoami
96+
npx -y --package=@web3-storage/w3cli@latest -- w3 whoami
97+
98+
# convert base64 env var to file
99+
echo $W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING | base64 -d > ipfs-webui-ci-space.ucan.proof
100+
101+
# Add space
102+
export W3CLI_SPACE_DID=$(npx -y --package=@web3-storage/w3cli@latest -- w3 space add ipfs-webui-ci-space.ucan.proof)
103+
104+
# use space
105+
npx -y --package=@web3-storage/w3cli@latest -- w3 space use $W3CLI_SPACE_DID
106+
107+
# upload car
108+
npx -y --package=@web3-storage/w3cli@latest -- w3 up --no-wrap -c ipfs-webui_${{ github.sha }}.car
94109
env:
95-
ESTUARY_API_TOKEN: ${{ secrets.ESTUARY_API_TOKEN }}
96-
PIN_CID: ${{ steps.ipfs.outputs.cid }}
97-
PIN_NAME: "ipfs-webui@${{ github.sha }}"
110+
W3_STORE_NAME: ipfs-webui-ci
111+
W3_AGENT_DID: ${{ secrets.W3_AGENT_DID }}
112+
# set w3cli principal from https://github.com/web3-storage/w3cli#w3_principal
113+
W3_PRINCIPAL: ${{ secrets.W3_AGENT_PRINCIPAL }}
114+
W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING: ${{ secrets.W3CLI_SPACE_DELEGATION_PROOF_BASE64_STRING }}
98115

99116
- name: Pin to ipfs-websites.collab.ipfscluster.io
100117
id: pin-cluster
118+
# only pin for main commits
119+
if: github.ref == 'refs/heads/main'
101120
continue-on-error: true
102121
run: |
103122
ipfs-cluster-ctl --enc=json \
@@ -125,7 +144,8 @@ jobs:
125144
PIN_NAME: "ipfs-webui@${{ github.sha }}"
126145

127146
- name: Fail job due to pinning failure
128-
if: steps.pin-estuary.outcome == 'failure' && steps.pin-cluster.outcome == 'failure'
147+
# only fail if pinning failed for main commits
148+
if: github.ref == 'refs/heads/main' && steps.pin-w3up.outcome == 'failure' && steps.pin-cluster.outcome == 'failure'
129149
uses: actions/github-script@v6
130150
with:
131151
script: |

0 commit comments

Comments
 (0)