CoolFace
Apppublic

Calvinho98/SOP-n8n-coreV3

sourceHugging Facemitupdated 7mo agoView on Hugging Face
0likes
App README

N8n Free

This repository deploys n8n on Hugging Face Spaces with a Supabase Postgres backend. It ships with GitHub Actions to keep the Space alive, run health checks, and update n8n.

Quick start

  • —Fork this repo on GitHub.
  • —Create a Supabase project and run the keep-alive SQL.
  • —Create a Hugging Face Space (Docker) linked to your fork.
  • —Add Hugging Face Space secrets and variables (tables below).
  • —Add GitHub Actions secrets and variables (tables below).
  • —Update the Space remote in workflows and the local healthcheck script.
  • —Trigger the push or update workflow once.

Deployment guide (Hugging Face Spaces only)

1. Fork the repository

Fork this repo to your GitHub account.

2. Create a Supabase project

  1. 1.Create a new project at Supabase.
  2. 2.In SQL Editor, run:
sql
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');
  1. 1.Enable SSL in Project Settings > Database > SSL Configuration.
  2. 2.Collect database connection details from Project Settings > Database: host, port, database user, password, and database name.

3. Create a Hugging Face Space (Docker)

  1. 1.Create a new Space and choose Docker as the SDK.
  2. 2.Link it to your forked GitHub repository.
  3. 3.Pick a free hardware option.

4. Configure Hugging Face Space secrets

Add these as Secrets in the Space settings:

SecretValue
DB_POSTGRESDB_HOSTSupabase database host
DB_POSTGRESDB_PORTSupabase database port
DB_POSTGRESDB_DATABASEpostgres (or your database name)
DB_POSTGRESDB_USERSupabase database user
DB_POSTGRESDB_PASSWORDSupabase database password
DB_POSTGRESDB_SSL_CASupabase SSL certificate (full PEM)
N8N_ENCRYPTION_KEYRandom string, keep it stable

5. Configure Hugging Face Space variables

Add these as Variables in the Space settings:

VariableValue
DB_TYPEpostgres
DB_POSTGRESDB_SCHEMApublic
N8N_PORT7860
N8N_PROTOCOLhttps
N8N_HOST<owner>-<space>.hf.space
N8N_EDITOR_BASE_URLhttps://<owner>-<space>.hf.space
WEBHOOK_URLhttps://<owner>-<space>.hf.space
N8N_ENFORCE_SETTINGS_FILE_PERMISSIONStrue
N8N_PUSH_BACKENDwebsocket
N8N_DATABASE_SSL_REJECT_UNAUTHORIZEDtrue
N8N_PROXY_HOPS1
GENERIC_TIMEZONEYour timezone (optional)
TZYour timezone (optional)

Optional execution retention settings:

VariableValue
EXECUTIONS_DATA_SAVE_ON_PROGRESSfalse
EXECUTIONS_DATA_SAVE_ON_ERRORall
EXECUTIONS_DATA_SAVE_ON_SUCCESSnone
EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONSfalse
EXECUTIONS_DATA_PRUNEtrue
EXECUTIONS_DATA_MAX_AGE168

6. Configure GitHub Actions secrets and variables

Add these in your forked repo under Settings > Secrets and variables > Actions.

Secrets:

SecretRequiredDescription
HF_TOKENYesHugging Face token with write access
SUPABASE_URLYesSupabase project URL (for keep-alive)
SUPABASE_KEYYesSupabase anon public key (for keep-alive)
TG_TOKENNoTelegram bot token (healthcheck alerts)
TG_CHAT_IDNoTelegram chat ID (healthcheck alerts)

Variables:

VariableRequiredDescription
HF_REPOYesSpace repo path: <owner>/<space>

7. Confirm HF_REPO is set

HF_REPO is used to build the Hugging Face Space git remote. Make sure the Actions variable is set to owner/space for your fork.

Operations and automation

Update n8n version

Run the update-n8n.yml workflow manually. The scheduled trigger is commented out; uncomment it if you want automatic updates. It:

  1. 1.Checks the latest stable n8n version tag via GitHub releases/latest API (pre-releases are excluded).
  2. 2.Checks version-blocklist.txt (currently includes 2.10.0).
  3. 3.Updates the Dockerfile tag only when the latest version is not blacklisted.
  4. 4.Commits the change.
  5. 5.Pushes to the Hugging Face Space.

To block additional versions, edit version-blocklist.txt and add one version per line.

Push to Hugging Face on every commit

push-to-huggingface.yml pushes main to your Space whenever you push to GitHub.

Keep-alive workflows

  • —huggingface-keep-alive.yml pings your Space URL.
  • —supabase-keep-alive.yml pings the keep-alive table via REST. Both schedules are commented out by default; uncomment them to enable cron.

Health checks and rebuilds

healthcheck.yml runs every 10 minutes and calls healthcheck-rebuild.sh. It checks https://<owner>-<space>.hf.space/healthz/readiness (derived from HF_REPO) and forces a rebuild if unhealthy.

To run locally:

HF_REPO=<owner>/<space> \
HF_TOKEN=<your_hf_token> \
bash healthcheck-rebuild.sh

Optional Telegram alerts:

TG_TOKEN=<bot_token> TG_CHAT_ID=<chat_id>

Optional n8n workflow

Import Auto keep n8n alive and updates on n8n-free repo.json into n8n if you want an in-app workflow for keep-alive and update triggers.

Troubleshooting

  • —Healthcheck fails with missing HF_REPO: Set HF_REPO in GitHub repo variables using owner/space format.
  • —Database SSL errors: Ensure SSL is enabled in Supabase and DB_POSTGRESDB_SSL_CA contains the full PEM certificate.
  • —Webhooks point to the wrong host: Align N8N_HOST, N8N_EDITOR_BASE_URL, and WEBHOOK_URL to the Space host.

Security notes

Do not commit secrets. Use Hugging Face Space secrets and GitHub Actions secrets.