hbstarjason/n8n
N8n Free
This repository provides a template for deploying a free, self-updating instance of n8n on Hugging Face Spaces, using Supabase as the database backend.
The setup includes automated GitHub Actions to:
- Keep the Hugging Face Space and Supabase project alive.
- Check for new n8n versions daily and automatically update the deployment.
Deployment Guide
Follow these steps to deploy your own free n8n instance.
1. Fork the Repository
Start by forking this repository to your own GitHub account.
2. Create a Supabase Project
- Go to Supabase and create a new project.
- Once the project is created, navigate to the SQL Editor.
- Run the following SQL query to create a
keep-alivetable. This is used by the keep-alive workflow to ensure your Supabase instance doesn't get paused due to inactivity.
CREATE TABLE "keep-alive" (
id BIGINT generated BY DEFAULT AS IDENTITY,
name text NULL,
created_at timestamptz DEFAULT now(),
CONSTRAINT "keep-alive_pkey" PRIMARY KEY (id)
);
INSERT INTO "keep-alive"(name) VALUES ('ping');- Navigate to Project Settings > API and find your Project URL and annon public legacy API key. You will need these in the next step.
- To ensure a secure connection to your database, you should configure SSL. In your Supabase project, go to Project Settings > Database. Scroll down to SSL Configuration and enable it.
3. Create a Hugging Face Space
- Go to Hugging Face Spaces and create a new Space.
- Select Docker as the Space SDK and choose a free hardware option.
- Choose the forked repository from your GitHub account to deploy from.
- After the Space is created, go to the Settings tab and add the following secrets and variables:
4. Configure GitHub Repository Secrets
To allow the GitHub Actions to update your Hugging Face Space, you need to add your Hugging Face API token to your forked repository's secrets.
- Create a Hugging Face token with write permissions at huggingface.co/settings/tokens.
- In your forked GitHub repository, go to Settings > Secrets and variables > Actions.
- Create a new secret named
HF_TOKENand paste your Hugging Face token.
5. Health Checks
You can configure a crontab to run the healthcheck-rebuild.sh to perform a health check of the n8n instance. It will try to make a commit to make it rebuild the n8n instance. You shoule pass the environment variables HF_REPO, N8N_HOST, TG_TOKEN(optional) to the script.
How It Works
This project uses GitHub Actions to automate maintenance and updates.
You can import the workflow Auto keep n8n alive and updates on n8n-free repo into n8n to make it keep alive and update itself.
Automatic n8n Updates
The .github/workflows/update-n8n.yml can triggered manually. After the n8n deploy, you can create a workeflow to trigger the github workeflow automatically.
- Checks for new n8n versions: It fetches the latest version tag from the official n8n GitHub repository.
- Compares versions: It compares the latest version with the version currently specified in the
Dockerfile. - Updates and Pushes: If a new version is found, the workflow:
- Updates the
Dockerfilewith the new version tag. - Commits the change to your repository.
- Pushes the updated
Dockerfileto your Hugging Face Space, triggering a rebuild and updating your n8n instance.
You can also trigger this workflow manually from the Actions tab in your GitHub repository.
Keep-Alive Services
To prevent the free tiers of Hugging Face Spaces and Supabase from being paused due to inactivity.
- Hugging Face Keep-Alive (`huggingface-keep-alive.yml`): This workflow sends a simple
curlrequest to your Hugging Face Space URL to simulate traffic. - Supabase Keep-Alive (`supabase-keep-alive.yml`): This workflow sends a
curlrequest to thekeep-alivetable in your Supabase database, ensuring the database remains active.
Configuring Keep-Alive Actions
To make the keep-alive workflows functional, you need to:
- Update the Hugging Face Keep-Alive URL:
- Create a new variable named
HF_SPACE_URLand paste your actual Hugging Face Space URL.
- Add Supabase Secrets to GitHub:
- In your forked GitHub repository, go to Settings > Secrets and variables > Actions.
- Create a new secret named
SUPABASE_URLand paste your Supabase Project URL. - Create another new secret named
SUPABASE_KEYand paste your Supabaseanon publicAPI key.
