ci: pinning new ipfs hash on 4EVERLAND #38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - "*" | |
| # Cancel in-progress runs when a new commit is pushed | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| outputs: | |
| cache-hit: ${{ steps.cache-deps.outputs.cache-hit }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js using mise | |
| uses: jdx/mise-action@v2 | |
| with: | |
| cache: true | |
| - name: Cache dependencies | |
| id: cache-deps | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.local/share/pnpm/store | |
| node_modules | |
| key: ${{ runner.os }}-deps-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-deps- | |
| - name: Install dependencies | |
| if: steps.cache-deps.outputs.cache-hit != 'true' | |
| run: pnpm install --frozen-lockfile | |
| lint: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js using mise | |
| uses: jdx/mise-action@v2 | |
| with: | |
| cache: true | |
| - name: Restore dependencies | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| ~/.local/share/pnpm/store | |
| node_modules | |
| key: ${{ runner.os }}-deps-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| - name: Lint | |
| run: pnpm lint | |
| test: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js using mise | |
| uses: jdx/mise-action@v2 | |
| with: | |
| cache: true | |
| - name: Restore dependencies | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| ~/.local/share/pnpm/store | |
| node_modules | |
| key: ${{ runner.os }}-deps-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| - name: Test with coverage | |
| run: pnpm test:coverage | |
| build: | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js using mise | |
| uses: jdx/mise-action@v2 | |
| with: | |
| cache: true | |
| - name: Restore dependencies | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| ~/.local/share/pnpm/store | |
| node_modules | |
| key: ${{ runner.os }}-deps-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| - name: Cache Next.js build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.next/cache | |
| .next/cache | |
| key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- | |
| - name: Build and export | |
| run: pnpm export | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: success() | |
| with: | |
| name: build-output | |
| path: out/ | |
| retention-days: 7 | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-output | |
| path: ./out | |
| - name: Deploy to IPFS | |
| env: | |
| IPFS_DEPLOY_URL: https://ipfs.nipsys.dev/api/deploy | |
| IPFS_API_KEY: ${{ secrets.IPFS_API_KEY }} | |
| PIN_4EVER_TOKEN: ${{ secrets.PIN_4EVER_TOKEN }} | |
| run: | | |
| # Create tar.gz of the site | |
| tar -czf site.tar.gz -C out . | |
| # Upload to IPFS deploy endpoint | |
| RESPONSE=$(curl -X POST \ | |
| -H "X-API-Key: $IPFS_API_KEY" \ | |
| --data-binary @site.tar.gz \ | |
| "$IPFS_DEPLOY_URL") | |
| echo "Deploy response: $RESPONSE" | |
| IPFS_HASH=$(echo "$RESPONSE" | jq -r '.hash') | |
| IPNS_HASH=$(echo "$RESPONSE" | jq -r '.ipns_hash') | |
| SUCCESS=$(echo "$RESPONSE" | jq -r '.success') | |
| if [ "$SUCCESS" = "true" ]; then | |
| echo "✅ Deploy successful!" | |
| echo "IPFS Hash: $IPFS_HASH" | |
| echo "IPNS Name: $IPNS_HASH" | |
| echo "Site available at: https://nipsys.eth.limo" | |
| else | |
| echo "❌ Deploy failed" | |
| exit 1 | |
| fi | |
| # Pinning attempt on 3rd party gateways | |
| echo "Pinning to 4EVERLand" | |
| LIST_RESP=$(curl --request GET \ | |
| --url https://api.4everland.dev/pins \ | |
| --header "authorization: Bearer $PIN_4EVER_TOKEN") | |
| REQUESTID=$(echo "$LIST_RESP" | jq -r '.results[] | select(.pin.name == "site") | .requestid') | |
| if [ -z "$REQUESTID" ]; then | |
| echo "⚠️ WARNING: No matching pin found for name 'site' in 4EVERLand. Skipping pin request." | |
| exit 0 | |
| fi | |
| PIN_RESP=$(curl --request POST \ | |
| --url https://api.4everland.dev/pins/$REQUESTID \ | |
| --header "authorization: Bearer $PIN_4EVER_TOKEN" \ | |
| --header "content-type: application/json" \ | |
| --data '{ | |
| "cid": "'$IPFS_HASH'", | |
| "name": "site" | |
| }') | |
| PIN_STATUS=$(echo "$PIN_RESP" | jq -r '.status') | |
| echo "PINNING STATUS: $PIN_STATUS" |