Deploying with GitHub Actions
Once your fork is set up, GitHub Actions can deploy Pixelflare for you, so you never need to run make deploy from your own machine. The Deploy workflow runs the same steps as an automated deployment, just on a clean runner.
Before You Start
You'll need a fork of Pixelflare on GitHub, and everything from steps 2 and 3 of the automated deployment guide:
- A Cloudflare API token and your account ID
- A domain on Cloudflare
- The R2 bucket for Terraform state, and its access keys
CI and your own machine share that state bucket, so you can deploy from either. If you deployed before remote state existed, move your local state into R2 first, or the workflow will try to recreate everything.
1. Add Your Secrets
In your fork, go to Settings → Environments, create an environment called production, and add these as environment secrets:
| Secret | Value |
|---|---|
CLOUDFLARE_API_TOKEN | Your Cloudflare API token |
CLOUDFLARE_ACCOUNT_ID | Your Cloudflare account ID |
DOMAIN | The domain Pixelflare runs on |
TF_STATE_ACCESS_KEY_ID | Access key for the Terraform state bucket |
TF_STATE_SECRET_ACCESS_KEY | Secret key for the Terraform state bucket |
Then add any other environment variables you'd normally put in .env, with the same names. The workflow builds its .env from these secrets, and anything you leave out gets its default.
GitHub doesn't allow secret names starting with GITHUB_, so these three use a GH_ prefix instead:
GITHUB_OAUTH_CLIENT_IDbecomesGH_OAUTH_CLIENT_IDGITHUB_OAUTH_CLIENT_SECRETbecomesGH_OAUTH_CLIENT_SECRETGITHUB_SPONSORS_CHECK_ENABLEDbecomesGH_SPONSORS_CHECK_ENABLED
2. Run a Deploy
Forks start with Actions turned off, so open the Actions tab and enable them first.
Then go to Actions → 🚀 Deploy → Run workflow, and pick your main branch. The run sets up your infrastructure, builds and deploys everything, then finishes with smoke tests and a short summary.
Only one deploy runs at a time. If you start another while one is going, it waits its turn.
3. Deploy Each Release (Optional)
The Deploy workflow also runs whenever a version tag like v1.2.3 is pushed. You can push tags yourself, or let the Tag workflow do it:
- You merge a pull request into
mainthat changes something that ships, likepackages/,terraform/,scripts/or theMakefile - Tag bumps the patch version, commits it to
main, and pushes a new tag - The tag starts Deploy
Tag needs a repository secret called BOT_TOKEN. Create a fine-grained personal access token for your fork with Contents: Read and write, and add it under Settings → Secrets and variables → Actions. It can't use GitHub's built-in token, because tags pushed with that one don't start other workflows.
Pushing straight to main doesn't create a tag. To release what's there, run Actions → 🔖 Tag → Run workflow, optionally with a version number.
Other Workflows
Your fork comes with a few more workflows:
- 🚦 CI checks every pull request, see CI/CD Pipeline
- 🚀 Release drafts a GitHub release for each version ending in
.0, likev1.3.0 - 🪞 Mirror copies the repo to Codeberg. It needs an SSH key you won't have, so disable it from its page in the Actions tab
Troubleshooting
- Missing required environment variables: the Generate .env from secrets step lists which ones. Check they're in the
productionenvironment and spelt the same as in.env - Terraform can't read its state: check the two
TF_STATE_secrets, and that the bucket is in the same Cloudflare account - A later step failed: fix the cause and re-run the workflow. Like
make deploy, it only changes what's out of date
See Troubleshooting for anything else, and Checking Logs to see what your instance is doing.