Git Product home page Git Product logo

add-to-web3's Introduction

add-to-web3

Upload files to web3.storage from a Github Action, and output the IPFS Content ID.

A lightweight wrapper around w3cli. As a composite github action all it does is configure and call the cli for you. See the steps in ./action.yml.

Usage

uses: web3-storage/add-to-web3@v3
id: w3up
with:
  path_to_add: 'dist'
  proof: ${{ secrets.W3_PROOF }}
  secret_key: ${{ secrets.W3_PRINCIPAL }}

# use the outputs in subsequent steps
# "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am"
- run: echo ${{ steps.w3up.outputs.cid }}

# "https://bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.w3s.link"
- run: echo ${{ steps.w3up.outputs.url }}

Generating a secret_key and proof

On your dev machine, use w3cli to generate a secret_key and proof to allow this action to upload to a space.

Install it from npm and login as described here https://web3.storage/docs/quickstart/ then create a key like this:

# Use the `did` in the input to the next command. 
# Use `key` as your `secret_key` for add_to_web3.
$ w3 key create --json
{
  "did": "did:key:z6Mk...",
  "key": "MgCaT7Se2QX9..."
}

Keep the key safe. Save it as a secret on your repo.

Copy the did for use in the next command. The output is a base64 encoded ucan proof that delegates capabilities to store/add and upload/add on your current space to the key generated above.

# Delegate capabilities to the `did` we created above.
$ w3 delegation create did:key:z6Mk... -c 'store/add' -c 'upload/add' --base64
mAYIEAP8OEaJlcm9vdHOAZ3ZlcnNpb24BwwUBcRIg+oHTbzShh1WzBo9ISkonCW+KAcy/+zW8Zb...

The capabilies store/add and upload/add are the minimum required to upload files to web3.storage. This proof will not allow that key to list uploads in this space for example.

To recap:

  • Use the key value from the output of w3 key create --json as the secret_key for this action.
  • Use the did value from that output as the audience for w3 delegation create <audience> shown above.
  • Use the output of w3 delegation create <audience> --base64 as the proof for this action.

Inputs

path_to_add

Required The path the root directory of your static website or other content that you want to publish to IPFS.

secret_key

Required The base64 encoded key to use to sign UCAN invocations to web3.storage.

Create one using w3 key create. See: https://github.com/web3-storage/w3cli#w3_principal

proof

Required A base64 encoded UCAN delegating capabilities the signing key above.

Create a proof using w3cli, delegating store/add' and upload/add`

$ AUDIENCE_DID="<the DID for secret_key created by `w3 key create`>"
$ w3 delegation create $AUDIENCE_DID  -c 'store/add' -c 'upload/add' --base64`
Show advanced options: hidden, wrap

hidden

Default false

Should hidden files prefixed with a . be included when found in the path_to_add

see: See: https://github.com/web3-storage/w3cli#w3-up-path-path

wrap

Default true

If path_to_add points to a file it will be wrapped in a directory to preserve the filename. To disable that set wrap: "true".

See: https://github.com/web3-storage/w3cli#w3-up-path-path

Outputs

cid

The IPFS content ID for the directory on IPFS. e.g. bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am

url

The IPFS gateway URL for the directory e.g. https://dweb.link/ipfs/bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am

Contributing

💌 Considerate contributions welcome!

add-to-web3's People

Contributors

dchoi27 avatar dependabot[bot] avatar hugomrdias avatar ljmf00 avatar olizilla avatar vasco-santos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

add-to-web3's Issues

Custom naming in input args

For now, name is picked by pickName

const name = pickName({
  repo: process.env.GITHUB_REPOSITORY,
  run: process.env.GITHUB_RUN_NUMBER,
  sha: process.env.GITHUB_SHA
})

Can we add custom name in input args? Thank you!

524: Origin Time-out

Can’t upload. Sometimes failed with Origin Time-out. Help please. Thank you.

Need to support new Web3.stoarge API

I have following error with web3-storage/add-to-web3@v2. When will V3 available? Thanks a lot !

Run web3-storage/add-to-web3@v2
with:
web_token: ***
path_to_add: build
include_hidden: false
web3_api: https://api.web3.storage/
wrap_with_directory: false
env:
NPM_CONFIG_USERCONFIG: /home/runner/work/_temp/.npmrc
NODE_AUTH_TOKEN: XXXXX-XXXXX-XXXXX-XXXXX
Adding build to https://api.web3.storage/
Error: This API feature has been sunset, and is no longer available. To continue uploading, use the new web3.storage API: https://web3.storage/docs.
image

Upgrade to work with w3up

This issue is to document how to use add-to-web3 with a w3up space. https://blog.web3.storage/posts/the-data-layer-is-here-with-the-new-web3-storage

I imagine I might need to pass a UCAN delegation to it and maybe also pass key material from a github secret that the ucan delegates to and that add-to-web3 can use to sign invocations of upload/add

Tasks

Add a section to the README about the correct format for `path_to_add`

I suggest adding documentation to the README outlining how path_to_add should be formatted. For instance, maybe including something like this:

  • path_to_add: "." will push the entire repo
  • path_to_add: "dir" will only push the contents of "dir"
  • check path_to_dir if you receive a "too many symbolic links encountered" error message

When I tried path_to_add: "/" (which I thought would push the entire repo) I received this error message:

Error: ELOOP: too many symbolic links encountered, stat '/bin/X11/X11/X11/X11/X11/...FileCheck-10'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.