├── .dockerignore ├── Dockerfile ├── README.md ├── action.yml ├── entrypoint.sh └── screenshot.png /.dockerignore: -------------------------------------------------------------------------------- 1 | # ignore all files by default 2 | * 3 | # include required files with an exception 4 | !entrypoint.sh 5 | !LICENSE 6 | !README.md 7 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM olizilla/ipfs-dns-deploy:1.8 2 | 3 | COPY "entrypoint.sh" "/entrypoint.sh" 4 | 5 | ENTRYPOINT ["/entrypoint.sh"] 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > [!CAUTION] 2 | > # ⛔️ Deprecation Warning 3 | > This GitHub Action is deprecated and no longer maintained. Use [**`ipfs-deploy-acton`**](https://github.com/ipfs/ipfs-deploy-action) instead, which has similar functionality and supports [IPFS Cluster](https://github.com/ipfs-cluster/ipfs-cluster/#readme), [Kubo](https://github.com/ipfs/kubo#readme), and other pinning services. 4 | 5 | ## IPFS Cluster GitHub Action 6 | 7 | Publish websites to [IPFS Cluster](https://ipfscluster.io/) as part of a Github Action workflow. This action pins a directory to IPFS by using the ipfs-cluster-ctl command to pin it to a remote IPFS Cluster. It sets the IPFS URL as a status on the commit that triggered the action, allowing easy previewing of rendered static sites on the dweb. 8 | 9 | **NOTE:** You need to provide **credentials to an IPFS cluster** instance that you have permission to pin to, in order to make use of this action. 10 | 11 | This action uses https://github.com/ipfs-shipyard/ipfs-dns-deploy to do the work. 12 | 13 | ![screenshot](screenshot.png) 14 | 15 | ## Usage 16 | 17 | Use this action from a workflow that build out your static site to a directory. In this example we ask ipfs-github-action to pin the `public` dir in the current workspace to cluster.ipfs.io 18 | 19 | ```yaml 20 | - uses: ipfs-shipyard/ipfs-github-action@v2 21 | id: ipfs 22 | with: 23 | path_to_add: public 24 | cluster_host: /dnsaddr/cluster.ipfs.io 25 | cluster_user: ${{ secrets.CLUSTER_USER }} 26 | cluster_password: ${{ secrets.CLUSTER_PASSWORD }} 27 | env: 28 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 29 | 30 | # "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am" 31 | - run: echo /ipfs/${{ steps.ipfs.outputs.cid }} 32 | 33 | # https://bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.link 34 | - run: echo ${{ steps.ipfs.outputs.url }} 35 | ``` 36 | 37 | Check the [filecoin spec website workflow](https://github.com/filecoin-project/specs/blob/71f37208a1f4f56b33ea307d7cbdb4b06996b115/.github/workflows/main.yml) for a complete example out in the wild that also updates a DNSLink record when with the new cid when a commit changes the production branch. 38 | 39 | 40 | ## Inputs 41 | 42 | ### `path_to_add` 43 | 44 | **Required** The path the root directory of your static website or other content that you want to publish to IPFS. 45 | 46 | ### `cluster_user` 47 | 48 | **Required** Username for the IPFS Cluster instance 49 | 50 | ### `cluster_password` 51 | 52 | **Required** Password for the IPFS Cluster instance 53 | 54 | ### `cluster_host` 55 | 56 | **Required** Multiaddr for the IPFS Cluster. - see: https://cluster.ipfs.io/ 57 | _Default_ `/dnsaddr/cluster.ipfs.io` 58 | 59 | ### `ipfs_gateway` 60 | 61 | **Required** IPFS subdomain gateway to use for preview url - see: https://docs.ipfs.io/concepts/ipfs-gateway 62 | _Default_ `dweb.link` 63 | 64 | If you'd prefer to use `/ipfs/` style preview urls, then v1 of this action is the one for you! 65 | 66 | see: https://github.com/ipfs-shipyard/ipfs-github-action/releases/tag/v1.0.0 67 | 68 | - Must be the hostname without a scheme prefix. e.g dweb.link not https://dweb.link 69 | - Links in commit status messages will be prefixed with https. http is not supported; GitHub prevents the `target_url` property from using http urls. 70 | 71 | ## Outputs 72 | 73 | ### `cid` 74 | 75 | The IPFS content identifier for the directory on IPFS. 76 | e.g. `bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am` 77 | 78 | More info on CIDs: https://docs.ipfs.io/concepts/content-addressing/ 79 | 80 | ### `url` 81 | 82 | The URL for the IPFS gateway to preview the content over https. 83 | e.g. https://bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.link 84 | 85 | More info on IPFS Gateways: https://docs.ipfs.io/concepts/ipfs-gateway 86 | 87 | ## Contribute 88 | 89 | Feel free to dive in! [Open an issue](https://github.com/ipfs-shipyard/ipfs-action/issues/new) or submit PRs. 90 | 91 | To contribute to IPFS in general, see the [contributing guide](https://github.com/ipfs/community/blob/master/contributing.md). 92 | 93 | [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) 94 | 95 | 96 | ## License 97 | 98 | [MIT](LICENSE) © Protocol Labs 99 | 100 | 101 | [`ipfs-cluster-ctl`]: https://cluster.ipfs.io/documentation/ipfs-cluster-ctl/ 102 | [`entrypoint.sh`]: scripts/pin-to-cluster.sh 103 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | # action.yml 2 | name: 'Add to IPFS Cluster' 3 | description: 'Pin a directory to an IPFS Cluster' 4 | author: olizilla 5 | branding: 6 | icon: 'box' 7 | color: 'blue' 8 | inputs: 9 | path_to_add: 10 | description: 'Directory path to add to IPFS' 11 | required: true 12 | cluster_user: 13 | description: 'Username for the IPFS Cluster instance' 14 | required: true 15 | cluster_password: 16 | description: 'Password for the IPFS Cluster instance' 17 | required: true 18 | cluster_host: 19 | description: 'Multiaddr for the IPFS Cluster' 20 | default: '/dnsaddr/cluster.ipfs.io' 21 | required: true 22 | ipfs_gateway: 23 | description: 'IPFS subdomain gateway to use for preview url' 24 | default: 'dweb.link' 25 | required: true 26 | outputs: 27 | cid: 28 | description: 'The IPFS Content ID for the directory' 29 | runs: 30 | using: 'docker' 31 | image: 'Dockerfile' 32 | args: 33 | - ${{ inputs.path_to_add }} 34 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # Interpolate env vars in the $INPUT_PATH_TO_ADD, see: https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#entrypoint 5 | # This handles situation where user provides path to add as $GITHUB_WORKSPACE/some/path 6 | INPUT_DIR=$(sh -c "echo $INPUT_PATH_TO_ADD") 7 | PIN_NAME="https://github.com/$GITHUB_REPOSITORY/commits/$GITHUB_SHA" 8 | 9 | echo "Pinning $INPUT_DIR to $INPUT_CLUSTER_HOST" 10 | 11 | update_github_status () { 12 | # only try and update the satus if we have a github token 13 | if [ -z "$GITHUB_TOKEN" ] ; then 14 | echo "Not setting status. No GITHUB_TOKEN set" 15 | return 0 16 | fi 17 | 18 | local STATE=$1 19 | local DESCRIPTION=$2 20 | local TARGET_URL=$3 21 | local CONTEXT='IPFS' 22 | local STATUS_API_URL="https://api.github.com/repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" 23 | local params 24 | params=$(jq --monochrome-output --null-input \ 25 | --arg state "$STATE" \ 26 | --arg target_url "$TARGET_URL" \ 27 | --arg description "$DESCRIPTION" \ 28 | --arg context "$CONTEXT" \ 29 | '{ state: $state, target_url: $target_url, description: $description, context: $context }' ) 30 | 31 | curl --output /dev/null --silent --show-error -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H 'Content-Type: application/json' --data "$params" $STATUS_API_URL 32 | } 33 | 34 | update_github_status "pending" "Pinnning to IPFS cluster" "https://$INPUT_IPFS_GATEWAY" 35 | 36 | # pin to cluster 37 | root_cid=$(ipfs-cluster-ctl \ 38 | --host "$INPUT_CLUSTER_HOST" \ 39 | --basic-auth "$INPUT_CLUSTER_USER:$INPUT_CLUSTER_PASSWORD" \ 40 | add \ 41 | --quieter \ 42 | --local \ 43 | --wait \ 44 | --cid-version 1 \ 45 | --name "$PIN_NAME" \ 46 | --recursive "$INPUT_DIR" ) 47 | 48 | preview_url="https://$root_cid.ipfs.$INPUT_IPFS_GATEWAY" 49 | 50 | update_github_status "success" "View on IPFS" "$preview_url" 51 | 52 | echo "Pinned to IPFS - $preview_url" 53 | 54 | echo "cid=$root_cid" >> $GITHUB_OUTPUT 55 | 56 | echo "url=$preview_url" >> $GITHUB_OUTPUT 57 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs-shipyard/ipfs-github-action/106d78958c71c334a8db97b516604de6ceb2b83b/screenshot.png --------------------------------------------------------------------------------