Skip to content

Commit f3c296c

Browse files
authored
Merge pull request #25 from ipfs/add-cluster-timeout
feat: add cluster pin expiry and custom pin names
2 parents b1c89c9 + 98c68f8 commit f3c296c

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## [1.4.0] - 2025-03-05
11+
12+
### Added
13+
14+
- Add support for time-bound pins in IPFS Cluster via the `cluster-pin-expire-in` input parameter.
15+
- Add support for custom pin names via the `pin-name` input parameter.
16+
1017
## [1.3.0] - 2025-03-05
1118

1219
### Added

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ The signing key and proof will be used as [inputs](#inputs) to the action.
8383
| `upload-car-artifact` | Upload and publish the CAR file on GitHub Action Summary pages | `'true'` |
8484
| `cluster-retry-attempts` | Number of retry attempts for IPFS Cluster uploads | `'5'` |
8585
| `cluster-timeout-minutes` | Timeout in minutes for each IPFS Cluster upload attempt | `'2'` |
86+
| `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. | - |
87+
| `pin-name` | Custom name for the pin. If unset, defaults to "{repo-name}-{commit-sha-short}" for both IPFS Cluster and Pinata. | - |
8688

8789
## Outputs
8890

action.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ inputs:
4343
description: 'IPFS Cluster CLI version to use'
4444
default: 'v1.1.2'
4545
required: false
46+
cluster-pin-expire-in:
47+
description: 'Time duration after which the pin will expire in IPFS Cluster (e.g. 720h for 30 days). Only supported by IPFS Cluster.'
48+
required: false
49+
pin-name:
50+
description: 'Custom name for the pin. If unset, defaults to "{repo-name}-{commit-sha-short}"'
51+
required: false
4652
storacha-key:
4753
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'
4854
required: false
@@ -207,6 +213,24 @@ runs:
207213
name: ipfs-cluster-ctl
208214
version: ${{ inputs.cluster-version }}
209215

216+
- name: Set pin name
217+
id: set-pin-name
218+
shell: bash
219+
run: |
220+
REPO_NAME=$(echo "${{ github.repository }}" | tr '/' '-')
221+
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
222+
COMMIT_SHA_SHORT="${COMMIT_SHA:0:7}"
223+
224+
# Set the pin name - either use the input or default to repo-commit format
225+
if [ -n "${{ inputs.pin-name }}" ]; then
226+
PIN_NAME="${{ inputs.pin-name }}"
227+
else
228+
PIN_NAME="${REPO_NAME}-${COMMIT_SHA_SHORT}"
229+
fi
230+
231+
echo "pin_name=${PIN_NAME}" >> "$GITHUB_ENV"
232+
echo "Using pin name: ${PIN_NAME}"
233+
210234
- name: Upload CAR to IPFS Cluster
211235
if: ${{ inputs.cluster-url != '' && inputs.cluster-user != '' && inputs.cluster-password != '' }}
212236
shell: bash
@@ -215,7 +239,7 @@ runs:
215239
IPFS_CLUSTER_USER: ${{ inputs.cluster-user }}
216240
IPFS_CLUSTER_PASSWORD: ${{ inputs.cluster-password }}
217241
run: |
218-
echo "ℹ️ Uploading CAR with CID ${{ steps.merkleize.outputs.cid }} to IPFS Cluster" >> $GITHUB_STEP_SUMMARY
242+
echo "ℹ️ Uploading CAR with CID ${{ steps.merkleize.outputs.cid }} to IPFS Cluster"
219243
220244
# run in a loop and retry
221245
attempt=1
@@ -239,9 +263,13 @@ runs:
239263
--basic-auth ${IPFS_CLUSTER_USER}:${IPFS_CLUSTER_PASSWORD} \
240264
add --format=car \
241265
--local \
242-
--name "${{ github.repository }}/${{ github.sha }}" \
266+
--name "${pin_name}" \
267+
${{ inputs.cluster-pin-expire-in != '' && format('--expire-in {0}', inputs.cluster-pin-expire-in) || '' }} \
243268
build.car && {
244269
echo "✅ Uploaded CAR with CID ${{ steps.merkleize.outputs.cid }} to IPFS Cluster" >> $GITHUB_STEP_SUMMARY
270+
if [[ -n "${{ inputs.cluster-pin-expire-in }}" ]]; then
271+
echo "⏰ IPFS Cluster Pin is set to expire in ${{ inputs.cluster-pin-expire-in }}" >> $GITHUB_STEP_SUMMARY
272+
fi
245273
exit 0
246274
}
247275
@@ -273,7 +301,7 @@ runs:
273301
shell: bash
274302
run: |
275303
ipfs pin remote service add pinata "${{ inputs.pinata-pinning-url }}" ${{ inputs.pinata-jwt-token }}
276-
ipfs pin remote add --service=pinata --background --name="build-${{ github.event.pull_request.head.sha || github.sha }}" ${{ steps.merkleize.outputs.cid }}
304+
ipfs pin remote add --service=pinata --background --name="${pin_name}" ${{ steps.merkleize.outputs.cid }}
277305
echo "✅ Pinned CID \`${{ steps.merkleize.outputs.cid }}\` to Pinata" >> $GITHUB_STEP_SUMMARY
278306
279307
- name: Set GitHub commit status

0 commit comments

Comments
 (0)