blog
GitHub CLI Auth with token from environment variable
Streamline Your Release Process: Automate GitHub Releases with GitHub CLI and CircleCI using this Handy Script!
You can use the github cli to automate release processes in continuous deployment situations. In CircleCI for instance set a context environment variable to the GitHub token for your user. Then in a script echo the variable into a file and read that with the Github cli. Be sure to unset the environment variable to ensure that the CLI does not complain (It checks the environment before executing to find your token and prevent use).
#!/bin/env bash
set -u
echo "$GITHUB_TOKEN" > .githubtoken
unset GITHUB_TOKEN
gh auth login --with-token < .githubtoken
rm .githubtoken
gh release create $VERSION --notes "Release $VERSION. $COMMIT_MESSAGE"
Run it to create a github release automatically in a shell with a temporary file:
GITHUB_TOKEN='your-token' VERSION='v0.0.1' COMMIT_MESSAGE='We did it' ./script.sh
CI release checklist for email-testing workflows
When you use GitHub CLI in CI for release automation, pair auth hygiene with delivery-test controls.
- Keep release tokens in CI secrets and rotate on a fixed cadence.
- Run prerelease inbox checks in Email Sandbox.
- Gate release with end-to-end assertions in Email Integration Testing.
- Publish delivery and failure events to your pipeline using Email Webhooks.
- Route retries and fallback actions via Email Automation Routing.
- Validate sender quality before broad rollout with Email Deliverability Test.