I have been working on a workflow that is able to back up my n8n workflows on github on a specific schedule. After the initial file(s) are made on github, it updates the GitHub file every few days.
However, I want to add a section where it only runs when if an edit has been made to the workflow(s) being backuped up on Github. Does anyone have any ideas as to how to go about this with an if-node (or another node)?
To prevent redundant commits, you can fetch the existing file’s SHA from the GitHub API and compare a cryptographic hash of your current workflow JSON against it using an n8n Code node before the If node. If the hashes match, skip the GitHub update node entirely to keep your commit history clean. Let me know what your current GitHub node response structure looks like and I can share the exact snippet for hash comparison right here.
I’d compare the actual file content rather than a normal hash directly against GitHub’s sha. The GitHub value is a Git blob SHA, so it won’t necessarily match a standard hash of the workflow JSON.
A safer flow would be:
Export the current workflow JSON.
Get the existing GitHub file and decode its Base64 content.
Normalize both versions in the same way, for example parse the JSON and serialize it consistently.
Compare the normalized content.
Only send the GitHub update when they differ.
Keep GitHub’s existing file SHA for the update request itself, but use the content comparison to decide whether an update is needed.
I’d also check whether the exported JSON contains metadata that changes without a meaningful workflow edit, otherwise the comparison may still create unnecessary commits.
Pull the workflow list from the n8n API and compare each updatedAt value to the time of your last backup run. Store that last-run time in a static data variable or a small sheet. Put an IF node after the compare so only changed workflows continue to the GitHub step. The commit node also gives you a sha, so you can skip when the content is identical.
Another option that avoids comparing file contents at all: n8n already tells you when a workflow was last edited.
The n8n node “Get many workflows” returns an updatedAt timestamp for each workflow.
Keep the time of your last successful backup, e.g. in a Code node with $getWorkflowStaticData('global'), and update it at the end of the run.
Add a Filter (or If) node: updatedAt is after the last backup time. Only those workflows go to the GitHub node.
Two catches: static data is only saved in production executions (scheduled/active), not when you test manually; and activating or deactivating a workflow also changes updatedAt, so you may get the odd extra commit. If that bothers you, run the content comparison Ayub described only on the workflows that pass the filter.