generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 31
/
action.yml
67 lines (54 loc) · 1.98 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: 'Add to web3'
description: 'Publish your files and websites to web3.storage'
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 encoded key to use to sign UCAN invocations. Create one using `w3 key create`. See: https://github.com/web3-storage/w3cli#w3_principal'
required: true
proof:
description: 'A base64 encoded UCAN delegating capabilities the secret signing key above. Create using `w3 delegation create --base64`'
required: true
hidden:
description: 'Include paths that start with "."'
required: false
default: 'false'
wrap:
description: 'If `path_to_add` points to a file it will be wrapped in a directory to preserve the filename. To disable that set wrap: "false"'
required: false
default: 'true'
outputs:
cid:
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: "composite"
steps:
- run: npm install -g @web3-storage/w3cli
shell: bash
- run: w3 space add ${{ inputs.proof }}
env:
W3_PRINCIPAL: ${{ inputs.secret_key }}
shell: bash
- run: w3 up ${{ inputs.path_to_add }} --json --hidden=${{ inputs.hidden }} --wrap=${{ inputs.wrap }} | 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 "cid=$(jq --exit-status --raw-output '.root."/"' ./w3_up_output.json)" >> "$GITHUB_OUTPUT"
shell: bash
- id: get_url
run: echo "url=https://${{ steps.get_cid.outputs.cid }}.ipfs.w3s.link" >> "$GITHUB_OUTPUT"
shell: bash