From d3e3ed3e2fb687dfbbb429c028b180240c4a5b9d Mon Sep 17 00:00:00 2001 From: M4K3R Date: Fri, 20 Nov 2026 19:24:30 +0800 Subject: [PATCH 1/2] ci: add Filebase pin step after Pinata pin Pin every deploy CID to Filebase via its IPFS Pinning Service API (POST https://api.filebase.io/v1/ipfs/pins, Bearer token, JSON {cid, name}), verified against the current Filebase docs: - re-pin existing CID: pinning-files guide -> Pinning Service API - auth: per-bucket Secret Access Token generated in the console (Access Keys -> IPFS RPC API endpoint -> Choose Bucket to Generate Token) - replace flow (POST /pins/{requestid}) reuses the existing 'site' pin on redeploy instead of stacking duplicate pins, mirroring the 4EVERLAND step The step fails the deploy on any error: non-200 list, non-202 create/replace, 'failed' pin status, or a 60s poll timeout. FILEBASE_TOKEN secret holds the pin token (falls back to FILEBASE_SECRET if the token was stored there). --- .github/workflows/ci.yml | 86 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edc24ed..609c388 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -273,3 +273,89 @@ jobs: fi echo "✅ Pin accepted by Pinata (CID: ${PINATA_CID})" + + - name: Pin to Filebase + env: + # Filebase IPFS Pinning Service API auth: a per-bucket Secret Access + # Token (Bearer). FILEBASE_TOKEN is the canonical secret; falls back + # to FILEBASE_SECRET if the owner stored the token there. + FILEBASE_TOKEN: ${{ secrets.FILEBASE_TOKEN || secrets.FILEBASE_SECRET }} + FILEBASE_CID: ${{ steps.deploy.outputs.cid }} + run: | + # Find the existing 'site' pin (PSA replace avoids duplicate pins on redeploy) + LIST_RESP=$(curl --silent --show-error --write-out '\n%{http_code}' \ + --url "https://api.filebase.io/v1/ipfs/pins?name=site&match=exact&limit=1" \ + --header "authorization: Bearer ${FILEBASE_TOKEN}") + + HTTP_CODE=$(echo "$LIST_RESP" | tail -n1) + LIST_BODY=$(echo "$LIST_RESP" | sed '$d') + + echo "Filebase pin list response (HTTP $HTTP_CODE):" + echo "$LIST_BODY" + + if [ "$HTTP_CODE" != "200" ]; then + echo "❌ Filebase pin list failed with HTTP $HTTP_CODE" + exit 1 + fi + + REQUESTID=$(echo "$LIST_BODY" | jq -r '.results[0].requestid // empty') + + if [ -z "$REQUESTID" ]; then + echo "No existing pin found, creating new pin..." + + PIN_RESP=$(curl --silent --show-error --write-out '\n%{http_code}' \ + --request POST \ + --url https://api.filebase.io/v1/ipfs/pins \ + --header "authorization: Bearer ${FILEBASE_TOKEN}" \ + --header "content-type: application/json" \ + --data "{\"cid\": \"${FILEBASE_CID}\", \"name\": \"site\"}") + else + echo "Found existing pin, replacing CID (requestid: ${REQUESTID})..." + + PIN_RESP=$(curl --silent --show-error --write-out '\n%{http_code}' \ + --request POST \ + --url "https://api.filebase.io/v1/ipfs/pins/${REQUESTID}" \ + --header "authorization: Bearer ${FILEBASE_TOKEN}" \ + --header "content-type: application/json" \ + --data "{\"cid\": \"${FILEBASE_CID}\", \"name\": \"site\"}") + fi + + HTTP_CODE=$(echo "$PIN_RESP" | tail -n1) + PIN_BODY=$(echo "$PIN_RESP" | sed '$d') + + echo "Filebase pin response (HTTP $HTTP_CODE):" + echo "$PIN_BODY" + + if [ "$HTTP_CODE" != "202" ]; then + echo "❌ Filebase pin failed with HTTP $HTTP_CODE" + exit 1 + fi + + REQUESTID=$(echo "$PIN_BODY" | jq -r '.requestid') + STATUS=$(echo "$PIN_BODY" | jq -r '.status') + echo "Pin accepted: REQUESTID=$REQUESTID, STATUS=$STATUS" + + # Poll for pinned status (max 60 seconds) + echo "Waiting for pin to finalize..." + for i in {1..12}; do + STATUS_RESP=$(curl --silent --show-error \ + --url "https://api.filebase.io/v1/ipfs/pins/${REQUESTID}" \ + --header "authorization: Bearer ${FILEBASE_TOKEN}") + + PIN_STATUS=$(echo "$STATUS_RESP" | jq -r '.status') + echo "Poll $i: STATUS=$PIN_STATUS" + + if [ "$PIN_STATUS" = "pinned" ]; then + echo "✅ Pin successful! (CID: ${FILEBASE_CID})" + exit 0 + elif [ "$PIN_STATUS" = "failed" ]; then + echo "❌ Pin failed!" + echo "$STATUS_RESP" | jq -r '.info' + exit 1 + fi + + sleep 5 + done + + echo "⚠️ TIMEOUT: Pin did not reach 'pinned' status within 60 seconds" + exit 1 From d7b47d2e706bee933997c9843aac401fe26b5cae Mon Sep 17 00:00:00 2001 From: M4K3R Date: Fri, 20 Nov 2026 19:49:07 +0800 Subject: [PATCH 2/2] ci: drop FILEBASE_SECRET fallback from Filebase pin step --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 609c388..4d87bca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -277,9 +277,8 @@ jobs: - name: Pin to Filebase env: # Filebase IPFS Pinning Service API auth: a per-bucket Secret Access - # Token (Bearer). FILEBASE_TOKEN is the canonical secret; falls back - # to FILEBASE_SECRET if the owner stored the token there. - FILEBASE_TOKEN: ${{ secrets.FILEBASE_TOKEN || secrets.FILEBASE_SECRET }} + # Token (Bearer). + FILEBASE_TOKEN: ${{ secrets.FILEBASE_TOKEN }} FILEBASE_CID: ${{ steps.deploy.outputs.cid }} run: | # Find the existing 'site' pin (PSA replace avoids duplicate pins on redeploy)