IPFS Automation

This guide has instructions to set up workflow which will run automatically to pin the latest hashes and create/update the transform rules set in Cloudflare whenever new version releases will be published across all apps.

Note: This tool is open-sourced by Kitkat Validator.

Releases:


Workflow setup

Step 1: Clone the repository - https://github.com/kitkatfund/ipfs-auto-deploy

Step 2: Install the dependencies with

Step 3: Copy the .env.sample file and rename it to .env

  1. Set the correct value for `MONGO_URI`. You can use any MongoDB instance, including one inside a self-hosted container. If you don't have a MongoDB instance, you can use the free tier of [MongoDB Atlas] as shown in the image below. Copy the URI marked by the arrow:

  1. Obtain your PINATA_JWT Token and set it in the .env file. Make sure to have the pinByHash and unpin permission enabled.

  2. Obtain your GITHUB_AUTH_TOKEN and set it in the .env file. No permissions are required if only fetching releases from public repositories.

  3. Obtain your CLOUDFLARE_API_TOKEN and set it in the .env file. Make sure to have the Zone.Transform Rules permissions for the API Token as shown in the image below.

    1. Account -> Account Rulesets -> Read

    2. Zone -> Transform Rules -> Read

    3. Zone -> Transform Rules -> Edit

Step 4: Create a Telegram Bot for deployment notifications.

  1. Set the TELEGRAM_BOT_TOKEN in the .env file

  2. Ensure to assign Group Admin Rights and Channel Admin Rights to the created bot using BotFather

  3. Create a new group, add your new bot to it, make it the group admin. Find out the chat ID of the group by checking https://web.telegram.org/a/ and selecting the group. The chat ID will be in the URL, it usually starts with -100 for groups that have bot admins. Set the TELEGRAM_CHAT_ID in the .env file.

Step 5: Create a new Cloudflare Transform Rule for each of the apps you want to pin.

Ignore this step if you already have transform rules setup for the IPFS apps.

The rules can have any values for now as our application will fix them for us. We just need to do this for the Rule ID to be available in the next step.

Step 6: Copy the src/utils/config.sample.ts file and rename it to src/utils/config.ts

  1. Add the appUUID, transformedURL, transformedURL inside cloudflareRuleExpression, cloudflareZoneId, cloudflareRulesetId and cloudflareRuleId for each of the apps. You can obtain the cloudflareZoneId by following the instructions in the Cloudflare documentation. The cloudflareRulesetId and cloudflareRuleId can be obtained by following the instructions on this page.

  2. Get your rulesetId querying the below URL and search for the object with phase: http_request_transform and copy that rulesetId. This becomes your cloudflareRulesetId.

curl https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets \ --header "Authorization: Bearer <API_TOKEN>"

  1. Now use this cloudflareRulesetId to query the below URL and get the respective cloudflareRuleId for individual transform rules and update it in src/utils/config.ts

curlhttps://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets /{ruleset_id} \ --header "Authorization: Bearer <API_TOKEN>"

Step 7: Please modify the appUUID, transformedURL, transformedURL inside cloudflareRuleExpression, cloudflareZoneId, cloudflareRulesetId and cloudflareRuleId as mentioned above and depending on your config.

Step 8: Deploy with a method of your choice, just like any backend application, Dockerfile is included.

Last updated