Automated deployment system that monitors Docker Hub for new stable n8n releases and automatically deploys them to Fly.io using GitHub Actions.
This repository contains a GitHub Actions workflow that:
- Checks Docker Hub daily for new stable n8n versions
- Compares the latest version with your currently deployed version
- Automatically deploys updates when a new stable version is available
- Preserves your existing configuration and data during updates
- A Fly.io account with an existing n8n application deployed
- A GitHub repository with this workflow
- Fly.io CLI access token
The workflow needs a Fly.io API token to authenticate and deploy updates.
Option A: Create a Deploy Token (Recommended)
# Install flyctl if you haven't already
# See: https://fly.io/docs/hands-on/install-flyctl/
# Authenticate with Fly.io
flyctl auth login
# Create a new deploy token (more secure, limited permissions)
flyctl tokens create deployOption B: Use Your Personal Token
# Get your personal access token
flyctl auth tokenπ‘ Tip: The deploy token is more secure as it has limited permissions.
After running the command, you'll see output like:
FlyV1 fm2_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
π Copy this token - you'll need it in the next step!
Now let's securely store the token in your GitHub repository:
-
Navigate to your repository on GitHub
- Go to
https://github.com/YOUR_USERNAME/YOUR_REPO
- Go to
-
Open Settings
- Click the βοΈ Settings tab at the top of your repository
-
Go to Secrets
- In the left sidebar, click Secrets and variables β Actions
-
Create New Secret
- Click the green New repository secret button
-
Configure the Secret
Name: FLY_API_TOKEN Value: [Paste your token from Step 1]β οΈ Important: The name must be exactlyFLY_API_TOKEN(case-sensitive) -
Save
- Click Add secret
β Done! Your token is now securely stored and will be masked in all logs.
Make sure your fly.toml file has your app name configured:
app = 'n8n-run' # β Your Fly.io app name
primary_region = 'ams'
[build]
image = 'n8nio/n8n'
# ... rest of your configThe workflow will automatically read your app name from this file.
π‘ Find your app name: Run
flyctl apps listto see all your Fly.io apps
The workflow is now configured and will run automatically. No additional setup needed!
What happens next:
- β° The workflow runs daily at 2:00 AM UTC to check for updates
- π It compares the latest n8n version with your deployed version
- π If a new stable version is found, it automatically deploys
- π You can view all activity in the Actions tab
Want to test it now? See the Manual Trigger section below.
The workflow runs automatically daily at 2:00 AM UTC to check for new versions.
To modify the schedule, edit .github/workflows/deploy-n8n.yml:
on:
schedule:
- cron: "0 2 * * *" # Change this to your preferred scheduleCron syntax examples:
0 2 * * *- Daily at 2:00 AM UTC0 */6 * * *- Every 6 hours0 0 * * 0- Weekly on Sunday at midnight
You can manually trigger the workflow at any time:
-
π Go to your GitHub repository
- Navigate to
https://github.com/YOUR_USERNAME/YOUR_REPO
- Navigate to
-
π¬ Open the Actions tab
- Click the Actions tab at the top
-
π Select the workflow
- In the left sidebar, click Deploy n8n to Fly.io
-
βΆοΈ Run the workflow- Click the Run workflow dropdown button (top right)
- Select the branch (usually
main) - Click the green Run workflow button
-
π Watch it run
- The workflow will appear in the list below
- Click on it to see real-time logs
β‘ Quick tip: This is useful for testing your setup or forcing an immediate update check!
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π Scheduled Trigger (Daily at 2 AM UTC) β
β or Manual Trigger β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π Step 1: Check Docker Hub β
β β’ Query Docker Hub API for n8n tags β
β β’ Filter out pre-releases (beta, alpha, rc) β
β β’ Find latest stable version (e.g., 1.23.4) β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π Step 2: Compare Versions β
β β’ Get current version from Fly.io β
β β’ Compare using semantic versioning β
β β’ Decide: Update needed? β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββ΄ββββββββββββ
β β
βΌ βΌ
β
Up to date π New version
β β
βΌ βΌ
Skip deploy βββββββββββββββββββββββββββββββββββ
β β π Step 3: Deploy β
β β β’ Deploy new Docker image β
β β β’ Preserve fly.toml config β
β β β’ Keep data volume intact β
β β β’ Run health checks β
β ββββββββββββ¬βββββββββββββββββββββββ
β β
βββββββββββββ¬ββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π Step 4: Report Results β
β β’ Log version information β
β β’ Create workflow summary β
β β’ Show success/failure status β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-
π Version Detection: Queries Docker Hub API for the latest stable n8n version
- Filters out pre-release versions (beta, alpha, rc)
- Uses semantic versioning to identify the latest stable release
-
π Version Comparison: Checks your currently deployed version on Fly.io
- Compares using semantic versioning rules
- Determines if an update is needed
-
π Deployment: If a new version is available
- Deploys the new Docker image to Fly.io
- Preserves your existing
fly.tomlconfiguration - Maintains your data volume (no data loss)
- Verifies deployment health after completion
-
π Reporting: Logs all actions and creates a workflow summary
- β Success: Reports the deployed version
- βοΈ No update: Confirms you're already up to date
- β Failure: Provides detailed error information
- π Go to your GitHub repository
- π¬ Navigate to Actions tab
- π Click on "Deploy n8n to Fly.io" workflow
- π View individual workflow runs and their logs
Each workflow run provides a summary showing:
| Status | Icon | Description |
|---|---|---|
| β Success | π | New version deployed successfully |
| βοΈ Skipped | β | Already running latest version |
| β Failed | Deployment encountered an error |
Example Summary:
π¦ Current Version: 1.22.5
π Latest Version: 1.23.4
π Action: Deployed new version
β
Status: Success
Problem: The Fly.io API token is missing or not properly configured.
Solution:
- Verify the secret is named exactly
FLY_API_TOKEN(case-sensitive) - Ensure the token has deployment permissions
- Try regenerating the token:
flyctl tokens create deploy - Re-add the token to GitHub Secrets
Problem: The API token is invalid or has expired.
Solution:
- Generate a new token:
flyctl tokens create deploy - Update the
FLY_API_TOKENsecret in GitHub with the new token - Re-run the workflow
Problem: Unable to query Docker Hub or parse version information.
Solution:
- Check if Docker Hub is accessible: https://hub.docker.com/r/n8nio/n8n/tags
- Review the workflow logs for specific error messages
- The workflow will automatically retry on the next scheduled run
Problem: The deployment completed but the application is not responding correctly.
Solution:
- Check your Fly.io dashboard: https://fly.io/dashboard
- View application logs:
flyctl logs - Check application status:
flyctl status - Fly.io's automatic rollback should restore the previous version
- Review your
fly.tomlconfiguration for any issues
Problem: A new version is available but the workflow didn't deploy it.
Solution:
- Check the workflow logs to see the version comparison
- Verify the new version is a stable release (not beta/alpha/rc)
- Manually trigger the workflow to force a check
- Review the version detection logic in the logs
Problem: The scheduled workflow is not executing.
Solution:
- Ensure the workflow file is in the default branch (usually
mainormaster) - Check that the repository is not archived or disabled
- Verify the cron syntax is correct
- Note: GitHub Actions may delay scheduled workflows during high load periods
The workflow is designed to preserve your existing configuration:
- fly.toml: All settings remain unchanged
- Data Volume: Your n8n workflows and data are preserved
- Environment Variables: All environment variables are maintained
- Only the Docker image version is updated
- API tokens are stored securely in GitHub Secrets
- Tokens are automatically masked in workflow logs
- The workflow uses minimal required permissions
- Concurrency control prevents simultaneous deployments
If you need to deploy a specific version manually:
# Deploy a specific version
flyctl deploy --image n8nio/n8n:1.23.4
# Or deploy the latest version
flyctl deploy --image n8nio/n8n:latest- n8n Documentation: https://docs.n8n.io/
- Fly.io Documentation: https://fly.io/docs/
- GitHub Actions Documentation: https://docs.github.com/en/actions
This workflow configuration is provided as-is for use with your n8n deployment.