Continuous Integration
Continuous integration is a software development practice in which developers regularly merge their code changes into a central repository. Automated builds and tests are then executed to verify the correctness of the new code before it is integrated into the main development branch. This approach aims to identify and resolve bugs quickly, enhance software quality, and accelerate the release process.
Continuous Deployment
Continuous deployment is a software development practice that automates the building and release of a project to production whenever new changes pass automated checks and are merged into the main branch. This approach enables frequent application updates, often multiple times a day, typically without users noticing the process.
The combination of Fly.io with GitHub Actions enables us to create a CI/CD pipeline in our development process. To achieve this, we need to follow the steps below:
I will assume you already have an app hosted on Fly.io and your repository on GitHub.
Generating a Fly API Deploy Token
To generate a Fly API deploy token, access your app and go to the 'Tokens' screen, as shown below:
Click 'New Token' to generate one, add a descriptive name, and copy the generated token. (Be sure to store it securely)
"### Creating the GitHub Actions Configuration File
In your project root, create the folder .github/workflows
and add the file fly-deploy.yml
inside it.
Next, copy and paste the following content into the newly created file (source):
# See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
name: Fly Deploy
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
concurrency: deploy-group # optional: ensure only one action runs at a time
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} # <-- SAME NAME OF GITHUB ACTIONS SECRETS
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
Any push to the main
branch will trigger the deployment process. Feel free to make any changes you deem necessary.
Configuring the Fly API Deploy Token in GitHub Actions
Now, go to your project's repository on GitHub and navigate to its settings. Then, go to the "Secrets and Variables" tab under the "Actions" section, as shown in the image below:
Next, create a new "Repository Secret". Make sure the name is the SAME as the one in the configuration file created earlier. In our case, it should be named "FLY_API_TOKEN".
Save it.
Now, any push to the main branch will trigger the build and deployment of your app to Fly.io.
Thank you!
Top comments (0)