IPFS Pinning GitHub Action

Learn how to configure the IPFS Pinning GitHub Action for use with Filebase.

What is IPFS Pinning GitHub Action?

IPFS Pinning GitHub Action is an open-source GitHub Action that enables developers to configure automatic backups for their GitHub repositories to an IPFS Pinning Service like Filebase whenever their GitHub repository’s main branch is pushed or updated by a pull request.

The GitHub repo for this action can be found here.

Read below to learn how to use IPFS Pinning GitHub Action with Filebase.

Prerequisites:

This tutorial uses the IPFS Pinning API, which is a paid feature that requires a Filebase IPFS Subscription.

1. Create a GitHub repository, or navigate to an existing repository. Select the 'Settings' tab.

2. From the left side bar menu, select 'Secrets', then 'Actions', then click the button 'New Repository Secret':

3. Repeat this step to create a second secret called FILEBASE_SECRET_KEY. This value should be your Filebase IPFS API Secret Token.

This token can be generated by navigating to the Filebase Access Keys page, then viewing the IPFS Pinning Service API Endpoint. Click the drop down menu for 'Choose Bucket to Generate Token', then choose the IPFS Filebase Bucket you want to use.

Then copy the generated Secret Access Token:

4. Select ‘Actions’ from the top menu bar.

5. In the GitHub Actions menu, select ‘Set Up a Workflow Yourself”.

6. Enter the following code into the new file, by default called main.yml:

on: [push]

jobs:
  pin_to_ipfs:
    runs-on: ubuntu-latest
    name: Publish
    steps:
    - uses: actions/checkout@v2
    - name: IPFS Publish
      id: IPFS
      uses: alexanderschau/ipfs-pinning-action@v1.0.0
      with:
        path_to_add: 'your/path/to/upload' 
        endpoint: 'https://api.filebase.io/v1/ipfs/pins'
        access_token: ${{ secrets.ACCESS_TOKEN }} 
        pin_name: 'github-actions-test'

Replace the following values to match your configuration:

  • path_to_add: The path to the files or folders in your GitHub repository you would like to upload to Filebase.

  • pin_name: A name to be associated with your file’s CID once pinned to IPFS.

The output of this action will be your file or folder’s IPFS CID value.

7. Then, select ‘Start Commit’ on the right side of the screen. Commit your file.

8. You will then see your main.yml file listed in your repository.

Select the ‘Actions’ tab from the menu bar again to check the status of the GitHub action, which was run automatically when it was committed. From here, it will be run automatically whenever the main branch of your repository is pushed to or merged with a pull request.

9. Your GitHub action will show a green check mark, meaning that it was able to run successfully.

10. You can verify that your GitHub repository files were uploaded to your Filebase bucket by checking the contents of your Filebase bucket on the web console.

If you have any questions, please join our Discord server, or send us an email at hello@filebase.com

Last updated