From 26e6149481add2eba35499a960373a63b9af3042 Mon Sep 17 00:00:00 2001 From: M4K3R Date: Fri, 20 Nov 2026 22:27:56 +0800 Subject: [PATCH] ci: pin to Pinata via CAR upload and decouple pin services pin_by_cid returns 403 on the Pinata free plan ('This feature is not supported by the current plan type'). Switch to the V3 Files API CAR upload (POST https://uploads.pinata.cloud/v3/files with car=true), which unpacks the CAR server-side and pins the contained root CID, preserving the deterministic CID computed by ipfs-deploy-action. The returned CID is checked against the deploy CID and mismatches fail. Give each pin step continue-on-error plus an id so one pin service failing no longer skips the others, and add a final 'Verify pin results' step that fails the job if any pin outcome was not success. --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbe5d3b..5962b25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -187,6 +187,8 @@ jobs: echo "Site available at: https://xav.gwei.site" - name: Pin to 4EVERLand + id: four-everland + continue-on-error: true env: PIN_4EVER_TOKEN: ${{ secrets.PIN_4EVER_TOKEN }} run: | @@ -255,31 +257,47 @@ jobs: exit 1 - name: Pin to Pinata + id: pinata + continue-on-error: true env: PINATA_JWT: ${{ secrets.PINATA_JWT }} PINATA_CID: ${{ steps.deploy.outputs.cid }} + CAR_PATH: ${{ steps.deploy.outputs.car-path }} run: | + # CAR upload unpacks server-side and pins the contained root CID, + # unlike pin_by_cid which requires a paid plan RESP=$(curl --silent --show-error --write-out '\n%{http_code}' \ --request POST \ - --url https://api.pinata.cloud/v3/files/public/pin_by_cid \ + --url https://uploads.pinata.cloud/v3/files \ --header "authorization: Bearer ${PINATA_JWT}" \ - --header "content-type: application/json" \ - --data "{\"cid\": \"${PINATA_CID}\", \"name\": \"site\"}") + --form "network=public" \ + --form "file=@${CAR_PATH}" \ + --form "name=site" \ + --form "car=true") HTTP_CODE=$(echo "$RESP" | tail -n1) BODY=$(echo "$RESP" | sed '$d') - echo "Pinata pin-by-CID response (HTTP $HTTP_CODE):" + echo "Pinata CAR upload response (HTTP $HTTP_CODE):" echo "$BODY" if [ "$HTTP_CODE" != "200" ]; then - echo "❌ Pinata pin failed with HTTP $HTTP_CODE" + echo "❌ Pinata CAR upload failed with HTTP $HTTP_CODE" exit 1 fi - echo "✅ Pin accepted by Pinata (CID: ${PINATA_CID})" + RETURNED_CID=$(echo "$BODY" | jq -r '.data.cid // empty') + + if [ "$RETURNED_CID" != "$PINATA_CID" ]; then + echo "❌ Pinata returned CID ${RETURNED_CID}, expected ${PINATA_CID}" + exit 1 + fi + + echo "✅ Pin accepted by Pinata (CID: ${RETURNED_CID})" - name: Pin to Filebase + id: filebase + continue-on-error: true env: # Filebase IPFS Pinning Service API auth: a per-bucket Secret Access # Token (Bearer). @@ -363,3 +381,17 @@ jobs: echo "⚠️ TIMEOUT: Pin did not reach 'pinned' status within 60 seconds" exit 1 + + - name: Verify pin results + if: always() + env: + EVERLAND_OUTCOME: ${{ steps.four-everland.outcome }} + PINATA_OUTCOME: ${{ steps.pinata.outcome }} + FILEBASE_OUTCOME: ${{ steps.filebase.outcome }} + run: | + echo "4EVERLAND: ${EVERLAND_OUTCOME} / Pinata: ${PINATA_OUTCOME} / Filebase: ${FILEBASE_OUTCOME}" + + if [ "$EVERLAND_OUTCOME" != "success" ] || [ "$PINATA_OUTCOME" != "success" ] || [ "$FILEBASE_OUTCOME" != "success" ]; then + echo "❌ One or more pin services failed" + exit 1 + fi