Skip to content

Commit 111685b

Browse files
committed
feat: subgraph build pinning
1 parent 31719c6 commit 111685b

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

.github/workflows/solidity.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,26 @@ jobs:
259259
yq -i e '.templates[].mapping.apiVersion = "0.0.7"' generated/scs.subgraph.yaml
260260
yq -i e '.templates[].network = "localhost"' generated/scs.subgraph.yaml
261261
npx graph codegen generated/scs.subgraph.yaml
262-
npx graph build --ipfs=https://ipfs.network.thegraph.com generated/scs.subgraph.yaml
262+
npx graph build --ipfs=https://ipfs.network.thegraph.com generated/scs.subgraph.yaml | tee build_output.txt
263263
else
264264
cd subgraph
265265
npx graph codegen subgraph.yaml
266-
npx graph build --ipfs=https://ipfs.network.thegraph.com subgraph.yaml
266+
npx graph build --ipfs=https://ipfs.network.thegraph.com subgraph.yaml | tee build_output.txt
267+
268+
# Extract and process IPFS hashes from the file
269+
ipfs_hashes=$(grep -oP 'Qm[a-zA-Z0-9]{44}' build_output.txt)
270+
for hash in $ipfs_hashes; do
271+
echo "Processing IPFS hash: $hash"
272+
curl -X POST -u "${{ secrets.INFURA_IPFS_API_KEY }}:${{ secrets.INFURA_IPFS_API_SECRET }}" "https://ipfs.infura.io:5001/api/v0/pin/add?arg=$hash"
273+
curl --request POST --url https://api.chainstack.com/v1/ipfs/pins/pinbycid \
274+
--header 'accept: application/json' \
275+
--header 'authorization: Bearer ${{ secrets.CHAINSTACK_API_KEY }}' \
276+
--header 'content-type: application/json' \
277+
--data "{\"cid\": \"$hash\"}"
278+
done
279+
280+
# Write IPFS hashes to a file
281+
echo "$ipfs_hashes" | sed 's/^/"/;s/$/"/' | paste -sd ',' > ipfs_hashes.txt
267282
fi
268283
269284
@@ -321,6 +336,16 @@ jobs:
321336
echo "\`\`\`" >> README.md
322337
cat all_allocations.json
323338
339+
- name: Add IPFS hashes to README if exists
340+
run: |
341+
if [ -f ipfs_hashes.txt ]; then
342+
echo "" >> README.md
343+
echo "## IPFS Hashes" >> README.md
344+
echo "\`\`\`" >> README.md
345+
cat ipfs_hashes.txt >> README.md
346+
echo "\`\`\`" >> README.md
347+
fi
348+
324349
- uses: JS-DevTools/npm-publish@v3
325350
with:
326351
token: ${{ secrets.NPM_TOKEN }}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)