Skip to content

Commit

Permalink
Merge pull request #5 from ipfs/feat/add-kubo
Browse files Browse the repository at this point in the history
feat: add support for CAR uploads to Kubo
  • Loading branch information
2color authored Feb 10, 2025
2 parents 181e08f + 885af1a commit 83be829
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 31 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [0.3.0] - 2025-02-10

### Added

- Add support for CAR uploads to Kubo via the Kubo RPC API.

### Removed

- Removed `cluster-upload-timeout` input as GitHub Actions does not support setting [timeout-minutes](https://github.com/actions/runner/blob/main/docs/adrs/0549-composite-run-steps.md#composite-run-steps-features) for steps in composite actions.

## [0.2.2] - 2025-02-10

### Fixed
Expand Down
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ The [composite action](https://docs.github.com/en/actions/sharing-automations/cr
## Features

- 📦 Merkleizes your static site into a CAR file
- 🚀 Uploads to IPFS via Storacha
- 🚀 Uploads CAR file to either Storacha, IPFS Cluster, or Kubo
- 📍 Optional pinning to Pinata
- 💾 Optional backup to Filebase
- 💾 Optional CAR file upload to Filebase
- 💬 PR comment with CID and preview links
- 🔗 Automatic preview links
- ✅ Commit status updates
Expand Down Expand Up @@ -41,36 +41,40 @@ The signing key and proof will be used as [inputs](#inputs) to the action.

## Inputs


### Required Inputs

| Input | Description |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `path-to-deploy` | Path to the directory containing the frontend build to merkleize into a CAR file and deploy to IPFS |
| `github-token` | GitHub token for updating commit status and PR comments |
| `cluster-url` | IPFS Cluster URL to pass to ipfs-cluster-ctl --host |
| `kubo-api-url` | Kubo RPC API URL to pass to `ipfs --api`, e.g. `/dns/YOUR_DOMAIN/tcp/443/https` |
| `kubo-api-auth` | Kubo RPC API auth secret to pass to `ipfs --api-auth`, e.g. `basic:hello:world` (defined as `AuthSecret` in `API.Authorizations` config) |
| `cluster-url` | IPFS Cluster URL to pass to `ipfs-cluster-ctl --host` |
| `cluster-user` | IPFS Cluster username for basic http auth |
| `cluster-password` | IPFS Cluster password for basic http auth |
| `storacha-key` | 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 |
| `storacha-proof` | Storacha Base64 encoded proof UCAN with capabilities for the space. Create one using `w3 delegation create did:key:DID_OF_KEY -c space/blob/add -c space/index/add -c filecoin/offer -c upload/add --base64` |

> [!IMPORTANT]
> To use this action, you must provide either IPFS Cluster credentials (inputs `cluster-url`, `cluster-user`, `cluster-password`), [Storacha](https://storacha.network) credentials (inputs `storacha-key`, `storacha-proof`), or both.
> To use this action, you must configure the inputs for either: **Kubo, IPFS Cluster, or Storacha**.
>
> - Kubo: `kubo-api-url` and `kubo-api-auth`
> - IPFS Cluster: `cluster-url`, `cluster-user`, `cluster-password`
> - Storacha: `storacha-key`, `storacha-proof`
### Optional Inputs

| Input | Description | Default |
| ------------------------ | ------------------------------------------------------------------------------ | -------------------------------- |
| `node-version` | Node.js version to use | `'20'` |
| `cluster-ctl-version` | IPFS Cluster CLI version to use | `'v1.1.2'` |
| `cluster-upload-timeout` | IPFS Cluster CAR upload timeout in minutes. If exceeded, the action will fail. | `5` |
| `kubo-version` | Kubo version to use for pinning | `'v0.33.0'` |
| `pinata-pinning-url` | Pinata Pinning Service URL | `'https://api.pinata.cloud/psa'` |
| `pinata-jwt-token` | Pinata JWT token for authentication | - |
| `filebase-bucket` | Filebase bucket name | - |
| `filebase-access-key` | Filebase access key | - |
| `filebase-secret-key` | Filebase secret key | - |
| `set-github-status` | Set GitHub commit status and PR comments | `'true'` |
| Input | Description | Default |
| --------------------- | ------------------------------------------------------- | -------------------------------- |
| `node-version` | Node.js version to use | `'20'` |
| `cluster-ctl-version` | IPFS Cluster CLI version to use | `'v1.1.2'` |
| `kubo-version` | Kubo CLI version to use for pinning API and CAR uploads | `'v0.33.0'` |
| `pinata-pinning-url` | Pinata Pinning Service URL | `'https://api.pinata.cloud/psa'` |
| `pinata-jwt-token` | Pinata JWT token for authentication | - |
| `filebase-bucket` | Filebase bucket name | - |
| `filebase-access-key` | Filebase access key | - |
| `filebase-secret-key` | Filebase secret key | - |
| `set-github-status` | Set GitHub commit status and PR comments | `'true'` |

## Outputs

Expand Down
50 changes: 36 additions & 14 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ inputs:
path-to-deploy:
description: 'Path to the directory containing the frontend build to merkleize into a CAR file and deploy to IPFS'
required: true
kubo-api-url:
description: 'Kubo RPC API URL to pass to `ipfs --api`, e.g. `/dns/YOUR_DOMAIN/tcp/443/https`'
required: false
kubo-api-auth:
description: 'Kubo RPC API auth secret to pass to `ipfs --api-auth`, e.g. `basic:hello:world` (defined as `AuthSecret` in `API.Authorizations` Kubo config)'
required: false
cluster-url:
description: 'IPFS Cluster URL to pass to ipfs-cluster-ctl --host, e.g. /dnsaddr/...'
required: false
Expand All @@ -21,10 +27,6 @@ inputs:
cluster-password:
description: 'IPFS Cluster password used for basic http auth'
required: false
cluster-upload-timeout:
description: 'IPFS Cluster upload timeout in minutes. If exceeded, the action will fail.'
default: 5
required: false
ipfs-cluster-ctl-version:
description: 'IPFS Cluster CLI version to use'
default: 'v1.1.2'
Expand Down Expand Up @@ -68,8 +70,14 @@ runs:
- name: Validate action inputs
shell: bash
run: |
if [[ -z "${{ inputs.storacha-key }}" || -z "${{ inputs.storacha-proof }}" ]] && [[ -z "${{ inputs.cluster-url }}" || -z "${{ inputs.cluster-user }}" || -z "${{ inputs.cluster-password }}" ]]; then
echo "::error::Either Storacha credentials (`storacha-key` and `storacha-proof`) or IPFS Cluster credentials (`cluster-url`, `cluster-user`, and `cluster-password`) must be configured"
# This checks if neither Storacha, IPFS Cluster, nor Kubo credentials are provided
# It validates that at least one of the three credential sets is complete:
# 1. Storacha: both key and proof must be set
# 2. IPFS Cluster: url, user and password must all be set
# 3. Kubo: api url and auth must both be set
# If all credential sets are incomplete/empty, it will error
if [[ -z "${{ inputs.storacha-key }}" || -z "${{ inputs.storacha-proof }}" ]] && [[ -z "${{ inputs.cluster-url }}" || -z "${{ inputs.cluster-user }}" || -z "${{ inputs.cluster-password }}" ]] && [[ -z "${{ inputs.kubo-api-url }}" || -z "${{ inputs.kubo-api-auth }}" ]]; then
echo "::error::Either Storacha credentials (`storacha-key` and `storacha-proof`) or IPFS Cluster credentials (`cluster-url`, `cluster-user`, and `cluster-password`) or Kubo credentials (`kubo-api-url` and `kubo-api-auth`) must be configured"
exit 1
fi
Expand Down Expand Up @@ -109,6 +117,28 @@ runs:
echo "- 🔗 [Service Worker Preview](https://inbrowser.link/ipfs/${{ steps.merkleize.outputs.cid }})" >> $GITHUB_STEP_SUMMARY
fi
- name: Setup Kubo CLI
if: ${{ inputs.pinata-jwt-token != '' || inputs.kubo-api-url != ''}}
uses: ipfs/download-ipfs-distribution-action@v1
with:
name: kubo
version: ${{ inputs.kubo-version }}

- name: Upload CAR to Kubo
if: ${{ inputs.kubo-api-url != '' && inputs.kubo-api-auth != ''}}
shell: bash
env:
KUBO_API_URL: ${{ inputs.kubo-api-url }}
KUBO_API_AUTH: ${{ inputs.kubo-api-auth }}
run: |
echo "ℹ️ Uploading CAR with CID ${{ steps.merkleize.outputs.cid }} to Kubo" >> $GITHUB_STEP_SUMMARY
if [ -n "${ACTIONS_RUNNER_DEBUG}" ]; then
export GOLOG_LOG_LEVEL='debug'
fi
ipfs dag import build.car --api ${KUBO_API_URL} --api-auth ${KUBO_API_AUTH}
echo "✅ Uploaded CAR with CID ${{ steps.merkleize.outputs.cid }} to Kubo" >> $GITHUB_STEP_SUMMARY
- name: Setup IPFS Cluster CLI
if: ${{ inputs.cluster-url != ''}}
uses: ipfs/download-ipfs-distribution-action@v1
Expand All @@ -119,7 +149,6 @@ runs:
- name: Upload CAR to IPFS Cluster
if: ${{ inputs.cluster-url != '' && inputs.cluster-user != '' && inputs.cluster-password != '' }}
shell: bash
timeout-minutes: ${{ inputs.cluster-upload-timeout }}
env:
IPFS_CLUSTER_URL: ${{ inputs.cluster-url }}
IPFS_CLUSTER_USER: ${{ inputs.cluster-user }}
Expand Down Expand Up @@ -158,13 +187,6 @@ runs:
exit 1
fi
- name: Setup Kubo
if: ${{ inputs.pinata-jwt-token != ''}}
uses: ipfs/download-ipfs-distribution-action@v1
with:
name: kubo
version: ${{ inputs.kubo-version }}

- name: Pin CID to Pinata
if: ${{ inputs.pinata-jwt-token != ''}}
shell: bash
Expand Down

0 comments on commit 83be829

Please sign in to comment.