-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: update to work with w3up api #89
Changes from 2 commits
0233765
395c2ed
636dfd4
506ecdf
2919f32
ac0f87e
2c07a4e
8fcd052
0dd07c7
70ca455
fcfcc0b
a9f7566
89d29ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
<h1 align="center">⁂<br/>web3.storage</h1> | ||
<p align="center">Add a directory to web3.storage from an Action, and output it's IPFS Content ID.</p> | ||
# add-to-web3 | ||
|
||
! v3 of this action will work with the new w3up api once https://github.com/web3-storage/add-to-web3/issues/87 lands. | ||
Upload files to web3.storage from a Github Action, and output it's IPFS Content ID. | ||
|
||
_A composite github action. It's [just yaml](./action.yml) calling [w3cli](https://github.com/web3-storage/w3cli_ | ||
|
||
olizilla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Example usage | ||
|
||
```yaml | ||
uses: web3-storage/add-to-web3@v2 | ||
id: web3 | ||
uses: web3-storage/add-to-web3@v3 | ||
id: w3 | ||
with: | ||
web3_token: ${{ secrets.WEB3_STORAGE_TOKEN }} | ||
path_to_add: 'dist' | ||
proof: ${{ secrets.W3_PROOF }} | ||
secret_key: ${{ secrets.W3_PRINCIPAL }} | ||
|
||
# "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am" | ||
- run: echo ${{ steps.web3.outputs.cid }} | ||
- run: echo ${{ steps.w3.outputs.cid }} | ||
|
||
# "https://dweb.link/ipfs/bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am" | ||
- run: echo ${{ steps.web3.outputs.url }} | ||
# "https://bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.w3s.link" | ||
- run: echo ${{ steps.w3.outputs.url }} | ||
``` | ||
|
||
## Inputs | ||
|
@@ -25,24 +27,20 @@ with: | |
|
||
**Required** The path the root directory of your static website or other content that you want to publish to IPFS. | ||
|
||
### `web3_token` | ||
|
||
**Required** API token for web3.storage | ||
### `secret_key` | ||
|
||
<details> | ||
<summary>Show advanced options: <code>wrap_with_directory</code>, <code>include_hidden</code>, <code>web3_api</code></summary> | ||
**Required** The base64 key to use to sign ucan invocations to web3.storage. | ||
|
||
olizilla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
### `wrap_with_directory` | ||
|
||
_Default_ `false` | ||
Create one using `w3 key create`. See: https://github.com/web3-storage/w3cli#w3_principal | ||
|
||
Should the `path_to_add` be wrapped in a diretory when creating the IPFS DAG. For most folks using this action the default of `false` is fine. | ||
### `proof` | ||
|
||
This is the opposite of the default that web3.storage uses, as this action is commonly used to add a directory that contains a static website to IPFS. In that case you want the path_to_add to become the root cid so you can host your site at `https://<cid>.ipfs.dweb.link` rather than `https://<cid>.ipfs.dweb.link/<path_to_add>`. | ||
**Required** A base64 encoded UCAN delegating capabilities the signing key above. | ||
|
||
If you do want to capture the `path_to_add` path itself in the IPFS DAG then you want to set `wrap_with_directory:true`. | ||
Create using `w3 delegation create --base64` | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we mention in the docs that delegation can be narrowed to a set of capabilities and they should make it only for their needs pointing to the docs https://github.com/web3-storage/w3cli?tab=readme-ov-file#w3-delegation-create-audience-did ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah it is good practice for us to recommend restricting caps. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may even be a good idea to change this to use limited capability set because this action only uploads no need to give the read access to it. |
||
see: https://web3.storage/docs/reference/js-client-library#parameters | ||
<details> | ||
<summary>Show advanced options: <code>include_hidden</code>, <code>no_wrap</code></summary> | ||
|
||
### `include_hidden` | ||
|
||
|
@@ -52,11 +50,12 @@ Should hidden files prefixed with a `.` be included when found in the `path_to_a | |
|
||
see: https://github.com/web3-storage/files-from-path#filesfrompath | ||
|
||
### `web3_api` | ||
|
||
_Default_ `https://api.web3.storage` | ||
### `no_wrap` | ||
|
||
_Default_ `false` | ||
|
||
Useful for testing against staging deployments by setting to the api origin of your choice. | ||
Advanced: if `path_to_add` points to a file it will be wrapped in a directory to preserve the filename. To disable that set no_wrap: "true". | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I find |
||
</details> | ||
|
||
|
@@ -72,11 +71,8 @@ e.g. `bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am` | |
The IPFS gateway URL for the directory | ||
e.g. `https://dweb.link/ipfs/bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am` | ||
|
||
|
||
## Contibuting | ||
|
||
💌 Considerate contributions welcome! | ||
|
||
The `dist` folder is commited to the repo as is the curious cultural norm with JS actions, as the repo is the delivery mechanism, so to spare some cycles for the user users, all the deps are bundled into a single /dist/index.js monolith. | ||
|
||
<h3 align="center"><a href="https://web3.storage">⁂</a></h3> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,30 +4,65 @@ author: olizilla | |
branding: | ||
icon: 'box' | ||
color: 'white' | ||
|
||
inputs: | ||
path_to_add: | ||
description: 'Directory path to add to IPFS' | ||
required: true | ||
|
||
secret_key: | ||
description: 'The base64 key to use to sign ucan invocations. Create one using `w3 key create`. See: https://github.com/web3-storage/w3cli#w3_principal' | ||
olizilla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
required: true | ||
|
||
proof: | ||
description: 'A base64 encoded UCAN delegating capabilities the signing key above. Create using `w3 delegation create --base64`' | ||
olizilla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
required: true | ||
|
||
include_hidden: | ||
description: 'Include hidden files' | ||
description: 'Include paths that start with "."' | ||
required: false | ||
default: 'false' | ||
web3_token: | ||
description: 'API token for web3.storage' | ||
required: true | ||
web3_api: | ||
description: 'API URL' | ||
required: false | ||
default: 'https://api.web3.storage' | ||
wrap_with_directory: | ||
description: 'Boolean. Default: `false`. Should the path_to_add be wrapped in a diretory when creating the IPFS DAG. For most folks using this, the default of `false` is fine. If you want to add a single file and preserve the filename in the IPFS DAG you may want to set it to `true`.' | ||
|
||
no_wrap: | ||
description: 'Advanced: if `path_to_add` points to a file it will be wrapped in a directory to preserve the filename. To disable that set no_wrap: "true"' | ||
required: false | ||
default: 'false' | ||
|
||
outputs: | ||
cid: | ||
description: 'The IPFS Content ID for the directory' | ||
description: 'The IPFS Content ID for path_to_add' | ||
value: ${{ steps.get_cid.outputs.cid }} | ||
|
||
url: | ||
description: 'The IPFS Gateway URL' | ||
value: ${{ steps.get_url.outputs.url }} | ||
|
||
runs: | ||
using: 'node16' | ||
main: 'dist/index.js' | ||
using: "composite" | ||
steps: | ||
# Use the branch while testing. | ||
- run: npm install -g github:web3-storage/w3cli#stringify | ||
shell: bash | ||
|
||
- run: w3 space add ${{ inputs.proof }} | ||
env: | ||
W3_PRINCIPAL: ${{ inputs.secret_key }} | ||
shell: bash | ||
|
||
- run: w3 up ${{ inputs.path_to_add }} --json | tee ./w3_up_output.json | ||
env: | ||
W3_PRINCIPAL: ${{ inputs.secret_key }} | ||
shell: bash | ||
|
||
# expect `./w3_up_output.json` to contain "{ "root": { "/": "bafy..." }} | ||
- name: fail if no CID in response | ||
run: jq --exit-status --raw-output '.root."/"' ./w3_up_output.json | ||
shell: bash | ||
|
||
- id: get_cid | ||
run: echo "::set-output name=cid::$(jq --exit-status --raw-output '.root."/"' ./w3_up_output.json)" | ||
shell: bash | ||
|
||
- id: get_url | ||
run: echo "::set-output name=url::https://${{ steps.get_cid.outputs.cid }}.ipfs.w3s.link" | ||
shell: bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deprecation warning
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: consider using same names here instead of secret key and principal?