Automatically update n8n version
๐ 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...
๐ Nodes & Integrations Used (2)
๐ Implementation & Setup Guide
๐ 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
- **Operating System:** Ubuntu 24.04
- **n8n Installation:** Docker container
---
๐ Project Directory Structure n8n/ โโโ check_update.txt โโโ check-update.sh โโโ compose.yml โโโ update_n8n.cron
---
๐งพ File Descriptions
`check_update.txt`
Contains a single word:
- `true`: Update is needed
- `false`: No update required
---
`check-update.sh`
```bash #!/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:**
- Checks the contents of `check_update.txt`
- If it contains `true`, executes update logic (currently a placeholder)
- Resets `check_update.txt` to `true`
- ---
- ### `update_n8n.cron`
```cron SHELL=/bin/sh 10 5 * * * /bin/sh /home/sysadmin/n8n/check-update.sh ``` **Purpose:**
- Runs the `check-update.sh` script daily at 5:10 AM
- Uses `/bin/sh` as the shell environment
๐งฉ n8n Workflow Breakdown
1. Schedule Trigger ๐ - **Purpose:** Triggers the workflow every day at 5:00 AM - **Node Type:** Schedule Trigger
---
2. Get the latest n8n version ๐ - **Purpose:** Fetches the latest version of n8n from npm - **Endpoint:** `https://registry.npmjs.org/n8n/latest` - **Node Type:** HTTP Request
---
3. Get Local n8n version ๐ฅ๏ธ - **Purpose:** Retrieves the currently running n8n version - **Endpoint:** `http://192.168.100.18:5678/rest/settings` - **Node Type:** HTTP Request
---
4. If ๐ - **Purpose:** Compares the local and latest versions - **Condition:** If not equal โ update is needed
---
5. SSH1 ๐งพ - **Purpose:** Writes the result to a file on the host via SSH - **Logic:**
```bash 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: ```bash crontab update_n8n.cron ``` ### 2. Verify that your cron job is registered: ```bash crontab -l ``` ## โ Result
- **5:00 AM** โ n8n workflow checks versions and writes result to `check_update.txt`
- **5:10 AM** โ Cron runs `check-update.sh` to respond to update flag
โก How to import this workflow into n8n:
- Click the Direct Download JSON button above to save
Automatically update n8n version.json. - Log in to your n8n Cloud or self-hosted n8n instance.
- In your workflow canvas, click the menu in top-right and select Import from File (or paste the JSON directly).
- Configure your credentials (e.g. API keys, database URLs) in the corresponding node settings.
- Click Execute Workflow to test and switch to Active!
Related DevOps & GitHub Workflows
View All in DevOps & GitHub โGenerate Google Doc Proposal
Production-ready n8n automation template for Generate Google Doc Proposal built by AhiXLight. Seamlessly connects Execute Workflow Trigger, Google Drive, OpenAI with 7 configured nodes.
Add a new lead to Pipedrive once GitHub repo is forked
This workflow automatically adds a new lead to Pipedrive once someone forks your GitHub repository. Prerequisites - Pipedrive account and Pipedrive credentia...
Add the affiliate to a program automatically
This workflow allows you to create an affiliate, add metadata, and add the affiliate to a program. !workflow-screenshot Tapfiliate node: This node allows you...
Add a note to Pipedrive s contact once PR is added on GitHub
This workflow automatically adds a note of the PR from GitHub to the Pipedrive contact if their GitHub email matches a Person in Pipedrive. Prerequisites - P...