Skip to content

Commit db1d147

Browse files
committed
feat: allow customising pin name
1 parent 6f4a725 commit db1d147

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ The signing key and proof will be used as [inputs](#inputs) to the action.
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'` |
8686
| `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. | - |
8788

8889
## Outputs
8990

action.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ inputs:
4646
cluster-pin-expire-in:
4747
description: 'Time duration after which the pin will expire in IPFS Cluster (e.g. 720h for 30 days). Only supported by IPFS Cluster.'
4848
required: false
49+
pin-name:
50+
description: 'Custom name for the pin. If unset, defaults to "{repo-name}-{commit-sha-short}"'
51+
required: false
4952
storacha-key:
5053
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'
5154
required: false
@@ -210,6 +213,24 @@ runs:
210213
name: ipfs-cluster-ctl
211214
version: ${{ inputs.cluster-version }}
212215

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+
213234
- name: Upload CAR to IPFS Cluster
214235
if: ${{ inputs.cluster-url != '' && inputs.cluster-user != '' && inputs.cluster-password != '' }}
215236
shell: bash
@@ -242,7 +263,7 @@ runs:
242263
--basic-auth ${IPFS_CLUSTER_USER}:${IPFS_CLUSTER_PASSWORD} \
243264
add --format=car \
244265
--local \
245-
--name "${{ github.repository }}/${{ github.sha }}" \
266+
--name "${pin_name}" \
246267
${{ inputs.cluster-pin-expire-in != '' && format('--expire-in {0}', inputs.cluster-pin-expire-in) || '' }} \
247268
build.car && {
248269
echo "✅ Uploaded CAR with CID ${{ steps.merkleize.outputs.cid }} to IPFS Cluster" >> $GITHUB_STEP_SUMMARY
@@ -280,7 +301,7 @@ runs:
280301
shell: bash
281302
run: |
282303
ipfs pin remote service add pinata "${{ inputs.pinata-pinning-url }}" ${{ inputs.pinata-jwt-token }}
283-
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 }}
284305
echo "✅ Pinned CID \`${{ steps.merkleize.outputs.cid }}\` to Pinata" >> $GITHUB_STEP_SUMMARY
285306
286307
- name: Set GitHub commit status

0 commit comments

Comments
 (0)