Skip to content
NEWMarketplace and the trig8n Agent: sell what you build, and get plans and changes that are tested before you see them. See what is new

Library / Code, Git & Developer Tools

Code, Git & Developer Tools

Restore n8n Workflows from Merged GitHub Pull Requests

When a pull request is merged in GitHub, it fetches the commit details and restores the changed workflows into n8n through the API.

What it does

## Setup 1. Connect GitHub: Use the GitHub Trigger node and configure GitHub API credentials. Note: I'd recommended to use *GitHub PAT (Personal Access Token) classic* with repo and admin:repo_hook permission scopes enabled. 2. Connect n8n API: Provide your n8n API credentials in the n8n nodes. - Check this doc 3. Set repository variables: Update github_owner and repo_name in the Define Local Variables node. 4. Enable webhook: Make sure your GitHub repository has a webhook for pull_request events pointing to this workflow.

The steps

  1. Define Local Variables
  2. Github Trigger - When there is new pull request
  3. Check if trigger event is pull request merged
  4. Fetch merged commit details via GitHub API
  5. Get files changes details
  6. Filter modified workflows
  7. Filter created workflows
  8. Fetch workflow content from Git
  9. Fetch workflow content from Git1
  10. Decode workflow content to json
  11. Decode workflow content to json1
  12. Update workflow in n8n
  13. Create new workflow in n8n

Similar automations