diff --git a/CHANGELOG.md b/CHANGELOG.md index 4639bd8..9a9028d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## [1.4.0] - 2025-03-05 + +### Added + +- Add support for time-bound pins in IPFS Cluster via the `cluster-pin-expire-in` input parameter. +- Add support for custom pin names via the `pin-name` input parameter. + ## [1.3.0] - 2025-03-05 ### Added diff --git a/README.md b/README.md index fbbfc7b..26fdc81 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,8 @@ The signing key and proof will be used as [inputs](#inputs) to the action. | `upload-car-artifact` | Upload and publish the CAR file on GitHub Action Summary pages | `'true'` | | `cluster-retry-attempts` | Number of retry attempts for IPFS Cluster uploads | `'5'` | | `cluster-timeout-minutes` | Timeout in minutes for each IPFS Cluster upload attempt | `'2'` | +| `cluster-pin-expire-in` | Time duration after which the pin will expire in IPFS Cluster (e.g. 720h for 30 days). If unset, the CID will be pinned with no expiry. | - | +| `pin-name` | Custom name for the pin. If unset, defaults to "{repo-name}-{commit-sha-short}" for both IPFS Cluster and Pinata. | - | ## Outputs diff --git a/action.yml b/action.yml index f407c99..ed32091 100644 --- a/action.yml +++ b/action.yml @@ -43,6 +43,12 @@ inputs: description: 'IPFS Cluster CLI version to use' default: 'v1.1.2' required: false + cluster-pin-expire-in: + description: 'Time duration after which the pin will expire in IPFS Cluster (e.g. 720h for 30 days). Only supported by IPFS Cluster.' + required: false + pin-name: + description: 'Custom name for the pin. If unset, defaults to "{repo-name}-{commit-sha-short}"' + required: false storacha-key: description: 'Storacha base64 encoded key to use to sign UCAN invocations. Create one using `w3 key create --json`. See: https://github.com/storacha/w3cli#w3_principal' required: false @@ -207,6 +213,24 @@ runs: name: ipfs-cluster-ctl version: ${{ inputs.cluster-version }} + - name: Set pin name + id: set-pin-name + shell: bash + run: | + REPO_NAME=$(echo "${{ github.repository }}" | tr '/' '-') + COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}" + COMMIT_SHA_SHORT="${COMMIT_SHA:0:7}" + + # Set the pin name - either use the input or default to repo-commit format + if [ -n "${{ inputs.pin-name }}" ]; then + PIN_NAME="${{ inputs.pin-name }}" + else + PIN_NAME="${REPO_NAME}-${COMMIT_SHA_SHORT}" + fi + + echo "pin_name=${PIN_NAME}" >> "$GITHUB_ENV" + echo "Using pin name: ${PIN_NAME}" + - name: Upload CAR to IPFS Cluster if: ${{ inputs.cluster-url != '' && inputs.cluster-user != '' && inputs.cluster-password != '' }} shell: bash @@ -215,7 +239,7 @@ runs: IPFS_CLUSTER_USER: ${{ inputs.cluster-user }} IPFS_CLUSTER_PASSWORD: ${{ inputs.cluster-password }} run: | - echo "ℹ️ Uploading CAR with CID ${{ steps.merkleize.outputs.cid }} to IPFS Cluster" >> $GITHUB_STEP_SUMMARY + echo "ℹ️ Uploading CAR with CID ${{ steps.merkleize.outputs.cid }} to IPFS Cluster" # run in a loop and retry attempt=1 @@ -239,9 +263,13 @@ runs: --basic-auth ${IPFS_CLUSTER_USER}:${IPFS_CLUSTER_PASSWORD} \ add --format=car \ --local \ - --name "${{ github.repository }}/${{ github.sha }}" \ + --name "${pin_name}" \ + ${{ inputs.cluster-pin-expire-in != '' && format('--expire-in {0}', inputs.cluster-pin-expire-in) || '' }} \ build.car && { echo "✅ Uploaded CAR with CID ${{ steps.merkleize.outputs.cid }} to IPFS Cluster" >> $GITHUB_STEP_SUMMARY + if [[ -n "${{ inputs.cluster-pin-expire-in }}" ]]; then + echo "⏰ IPFS Cluster Pin is set to expire in ${{ inputs.cluster-pin-expire-in }}" >> $GITHUB_STEP_SUMMARY + fi exit 0 } @@ -273,7 +301,7 @@ runs: shell: bash run: | ipfs pin remote service add pinata "${{ inputs.pinata-pinning-url }}" ${{ inputs.pinata-jwt-token }} - ipfs pin remote add --service=pinata --background --name="build-${{ github.event.pull_request.head.sha || github.sha }}" ${{ steps.merkleize.outputs.cid }} + ipfs pin remote add --service=pinata --background --name="${pin_name}" ${{ steps.merkleize.outputs.cid }} echo "✅ Pinned CID \`${{ steps.merkleize.outputs.cid }}\` to Pinata" >> $GITHUB_STEP_SUMMARY - name: Set GitHub commit status