This project demonstrates how to run an n8n instance on a GitHub Actions runner and expose it to the internet using a Cloudflare Tunnel. This provides a temporary, on-demand n8n environment that is created and torn down with each workflow run.
The GitHub Actions workflow defined in .github/workflows/main.yml automates the entire process:
- Checkout Code: The repository code is checked out.
- Setup Node.js: A Node.js environment is configured.
- Install Dependencies:
npm installis run to install n8n from thepackage.jsonfile. - Start n8n: The n8n server is started in the background on its default port (
5678). - Download
cloudflared: The Cloudflare Tunnel command-line tool (cloudflared) is downloaded and made executable. - Start Cloudflare Tunnel:
cloudflaredis started, creating a secure tunnel from the GitHub Actions runner to the Cloudflare network. This tunnel exposes the local n8n server (running onhttp://localhost:5678) to a public URL.
To use this workflow, you need to set up a Cloudflare Tunnel and add its token to your GitHub repository secrets.
-
Create a Cloudflare Tunnel: Follow the official Cloudflare guide to create a tunnel and get your tunnel token: Set up your first tunnel. You only need to complete the steps to create a tunnel and get the token; you do not need to install
cloudflaredon your local machine. -
Add the Tunnel Token to GitHub Secrets:
- In your GitHub repository, go to
Settings>Secrets and variables>Actions. - Click
New repository secret. - Create a new secret named
CLOUDFLARE_TUNNEL_TOKEN. - Paste the tunnel token you obtained from Cloudflare into the value field.
- In your GitHub repository, go to
The workflow is configured to run automatically on every push to the main branch. Once the workflow starts, you can view the logs to see the public URL assigned by Cloudflare Tunnel. The n8n instance will be available at that URL for the duration of the GitHub Actions job (up to 6 hours).
This is not a persistent hosting solution. The n8n server will only be available while the GitHub Actions job is running. When the job finishes or is canceled, the server and the tunnel will be terminated. This setup is intended for temporary testing, demonstrations, or short-lived automated tasks.