⚙️ Automatically update n8n version

2,153 views · ⚙️ DevOps & CI/CD

Description

🔄 n8n Workflow: Check and Update n8n Version

This workflow automatically checks if the local n8n version is outdated and, if so, creates a file to signal an update is needed.


🖥️ Working Environment


📁 Project Directory Structure

n8n/ ├── check_update.txt ├── check-update.sh ├── compose.yml ├── update_n8n.cron


🧾 File Descriptions

check_update.txt

Contains a single word:


check-update.sh

#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

if grep -q "true" /home/sysadmin/n8n/check_update.txt; then
    # Place your update logic here
    echo "Update needed - please insert update logic"
    echo true > /home/sysadmin/n8n/check_update.txt
fi

Purpose:


update_n8n.cron

SHELL=/bin/sh
10 5 * * * /bin/sh /home/sysadmin/n8n/check-update.sh

Purpose:

🧩 n8n Workflow Breakdown

1. Schedule Trigger 🕓


2. Get the latest n8n version 🌐


3. Get Local n8n version 🖥️


4. If 🔍


5. SSH1 🧾

echo "{{ $('If').params.conditions ? 'false' : 'true' }}" > check_update.txt

Effect: Updates check_update.txt with "true" if an update is needed, "false" otherwise.

🛠️ Setting up Crontab on Ubuntu

1. Register the cron job with:

crontab update_n8n.cron

2. Verify that your cron job is registered:

crontab -l

✅ Result

🔗 Nodes Used

HTTP Request, SSH, Schedule Trigger

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup