Quick overview This workflow runs nightly to back up all workflows from your n8n instance to a GitHub repository, creating a new JSON file for new workflows and only updating existing files when the workflow has changed to avoid unnecessary commits. How it works Runs every day at 11 PM on a schedule trigger. Retrieves a list of all workflows in your n8n instance using the n8n API and processes them one by one. Checks GitHub to see whether a backup JSON file already exists for the current workflow. If no file exists, fetches the full workflow JSON from n8n and creates a new file in the GitHub repository. If a file exists, calls the GitHub Commits API to get the latest commit date for that file and compares it to the workflow’s updatedAt date in n8n. If n8n is newer, downloads the latest workflow JSON and updates the existing file on GitHub; otherwise it skips updating to avoid creating a commit. Waits 10 seconds between GitHub operations to reduce the chance of hitting GitHub API rate limits. Setup Create an n8n API key and add an n8n API credential, then select it in the n8n nodes that list and fetch workflows.
Tags
Related workflows
See all GitHub→Display project data on a smashing dashboard
This workflow will gather data every minute from the GitHub (https://github.com), Docker (https://www.docker.com/), npm (https://www.npmjs.com/) and Product Hunt (https://www.producthunt.com/) website APIs and display select information on a Smashing (https://smashing.github.io/) dashboard. For convenience sake, the dashboard piece can be easily downloaded as a docker container (https://hub.docker.com/r/tephlon/n8n_dashboard) and installed into your docker environment.
Save your workflows into a GitHub repository
Basics Provides a mechanism to save all your workflows into a github repository and path (of your choosing). These can then be shared through your entire org and used to track changes (if you make any sad 'oopsies'. Flow Obtains and creates listing of currently configured workflows. Iterates through each workflow looking at the following Github source (if present) Actual workflow code (from N8N) Workflow code is sorted and compared for any changes If changed (or new) the workflows are saved / archived into github. Configuration Most of the configuration is done in the Globals node which houses the repo detail for github nodes. The only other dependency is that it by default looks for a GitHub credential, if you use something other than that precise wording you will need to change the credential used on the respective nodes. We gave it 'Manage' rights, but that was only so that it was able to override a requirement for checks to complete? Most would probably only need 'Write' privileges. Background Well, so we initially started using N8N just as a kubernetes-based service housed with its DB running inside the pod. Worked great for getting to know N8N and we jut kept all our workflow
Backup workflows to GitHub
Note: This workflow uses the internal API which is not official. This workflow might break in the future. The workflow executes every night at 23:59. You can configure a different time bin the Cron node. Configure the GitHub nodes with your username, repo name, and the file path. In the HTTP Request nodes (making a request to localhost:5678), create Basic Auth credentials with your n8n instance username and password.