EthDen 2: Pin projects to IPFS right from GitHub

ethereum Feb 15, 2020

In our post yesterday, we shared with you how to post dynamic directories to IPFS using Textile Buckets. Today, to keep your EthDen projects moving along quickly, I'll share with you the fastest way to add IPFS pinning to your team's project. You can use this to maintain a folder of images or publish an entire website. Here's how.

Setup a GitHub Action

GitHub Actions are an easy and free (if you are open-source) way to add CI to your project. If you are pushing a static webpage (or maybe dynamically building your page already with a framework), GitHub actions may help you get that page online faster.

To start, you can copy the example GitHub Action we created for you. In your project repo root, create a directory for your new Action.

mkdir -p .github/workflows

That's the director you'll be creating new actions. Do not add this folder to your .gitignore as you'll want it pushing to your repo.

Next, download our example action into the folder.

wget -O .github/workflows/bucket_push.yml https://raw.githubusercontent.com/textileio/github-action-bucket-push/master/.github/workflows/main.yml

If you look at the content of the file, the step that is pushing to your Textile bucket is the following,

- name: Bucket push action
  id: push
  uses: textileio/[email protected]
  with:
    bucket-name: 'bucket-push-action'
    path: '*'
    token: ${{ secrets.TEXTILE_AUTH_TOKEN }}

You need to change one or two of the parameters here.

  1. bucket-name should be the unique name of a bucket you created with Textile (or a brand new, never before used bucket name). See Part 1 if you need to learn how to create one.
  2. path is the path relative to the root of your repo that you want pushed to your bucket. By default, it pushes your whole repo. If you want to push a build folder such as build, just change it to path: build/*.

Next, you'll need to get your Textile auth token and add it to your project Secrets on GitHub. If you followed Part 1 or already have Textile setup on your local machine, you can find your token very quickly with, cat ~/.textile/auth.yml. This should output a string containing your token: <YOUR AUTH TOKEN>. Copy that token string and head to the Setting page on your GitHub repo.

Once on your Settings page, click Add a new secret. In the form, you put TEXTILE_AUTH_TOKEN in the name field and paste your private token into the value field. Click save.

Run your new Action

The example Action you created above is configured to run on Pull Requests or Pushes to Master. So let's go ahead and create a Pull Request or push you changes to Master to see it run.

After you push, you should now see the Action running in the Actions tab on your GitHub project page.

Once the Action completes, your bucket should be up dated on the web. You can verify it by visiting, https://<bucket-name>.textile.cafe

In our next Post, we'll show you how to use IPFS & DNS link to display the latest updates to your bucket on your webpage.

Win some Bounties!

There are a bunch of Bounties this year and some you are able to win simply by using Buckets to launch parts of your hack on IPFS! Check them out here, https://alchemy-xdai.daostack.io/dao/0x993c67b8830dac1bfda09e8be0dce8553cf84271/scheme/0xcb99e740cbbe2c293923c4032ea7b5beb5dae9260d9375a247cbd1c83c09b4aa

Here is a Bounty you can win just by using Buckets: https://alchemy-xdai.daostack.io/dao/0x993c67b8830dac1bfda09e8be0dce8553cf84271/proposal/0xf12dd3a509543a9212e96093f295ffeb918f05bfa6e1906873718070645306f5

If you want to learn more ways to use Textile this weekend (dynamic databases in your app, hosted IPFS, and more), take a look at our Bounty guide here, https://blog.textile.io/ethden-2020-textile-bounty-resources/

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.