Using Large Multi-line Secrets in Github Actions

Dhruva Sagar
TarkaLabs TIL
Published in
1 min readMay 30, 2022

GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.

While working on one of our product’s deployment workflow, I realised maintaining separate secret varaiables for each environment wasn’t going to scale. To solve this issue, it felt natural to move the environment configuration from multiple secrets to a single secret to be used as a large multiline env file.

However, a large multiline value gave me issues due to github automatically wrapping long lines. Notice how sometimes solving one issue leads you to another ? Well, to solve this issue, I resorted to base64 encoding. We base64 encode the large secret value and within the github action workflow, we decode it before using the encoded value. Here’s how :

Example deployment workflow for github action

And problem solved!

--

--

Dhruva Sagar
TarkaLabs TIL

hacker. loves to code, lives inside terminals, vim advocate, open source enthusiast.