{"product_id":"deploy-n8n-workflows-on-github-push-to-production-rest-api","title":"Deploy n8n Workflows on GitHub Push to Production (REST API)","description":"\u003ch3\u003eDeploy n8n workflows to production automatically on every GitHub push\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow listens for \u003cstrong\u003eGitHub push events\u003c\/strong\u003e, pulls the changed \u003cstrong\u003eexported n8n workflow JSON\u003c\/strong\u003e from your repository, and then \u003cstrong\u003eupdates or creates the matching workflow in your production n8n instance\u003c\/strong\u003e via the n8n \u003cstrong\u003eREST API\u003c\/strong\u003e. No manual import steps—just push to GitHub and ship.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eTriggers on GitHub push\u003c\/strong\u003e and checks the push is targeting the \u003cstrong\u003emain branch\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003eIgnores \u003cstrong\u003ebranch deletion\u003c\/strong\u003e events and proceeds only if there are \u003cstrong\u003eadded or modified files\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003eUses the \u003cstrong\u003eGitHub Contents API\u003c\/strong\u003e to request the changed workflow JSON file from the repository.\u003c\/li\u003e\n  \u003cli\u003eExtracts the \u003cstrong\u003eworkflow name\u003c\/strong\u003e from the fetched JSON.\u003c\/li\u003e\n  \u003cli\u003eQueries the \u003cstrong\u003eproduction n8n instance\u003c\/strong\u003e via the n8n REST API to find an existing workflow with the same name.\u003c\/li\u003e\n  \u003cli\u003eIf found, it removes deployment-specific fields (IDs\/metadata) from the GitHub JSON and \u003cstrong\u003eupdates\u003c\/strong\u003e the production workflow.\u003c\/li\u003e\n  \u003cli\u003eIf not found, it removes IDs\/metadata and \u003cstrong\u003ecreates\u003c\/strong\u003e a new workflow in production.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eGitOps for n8n:\u003c\/strong\u003e store exported workflows in GitHub and deploy to production on every change to \u003ccode\u003emain\u003c\/code\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSaaS operations:\u003c\/strong\u003e keep production workflows synchronized with version-controlled updates.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAutomation engineering:\u003c\/strong\u003e reduce drift by ensuring the live n8n workflow matches the JSON committed to GitHub.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eGitHub Trigger\u003c\/strong\u003e (push events) with GitHub OAuth2 credentials.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eHTTP Request\u003c\/strong\u003e to the \u003cstrong\u003eGitHub Contents API\u003c\/strong\u003e to fetch workflow JSON.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003en8n REST API\u003c\/strong\u003e calls to search, update, or create workflows in the production instance.\u003c\/li\u003e\n  \u003cli\u003eWorkflow logic uses nodes such as \u003cstrong\u003eif\u003c\/strong\u003e, \u003cstrong\u003eset\u003c\/strong\u003e, and \u003cstrong\u003ecode\u003c\/strong\u003e (with supporting notes and control flow).\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003cp\u003e\u003cstrong\u003eSetup:\u003c\/strong\u003e configure GitHub repo owner\/name, set your production n8n base URL, add the required GitHub OAuth2 and n8n API credentials, and ensure the trigger is set to the branch you deploy from (e.g., \u003ccode\u003emain\u003c\/code\u003e).\u003c\/p\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":45967517286579,"sku":"N8N-19270","price":5.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/5JBJPdYcmAuJbT6vDjndR_tzRMx3Sm.png?v=1788685566","url":"https:\/\/buyflowscripts.com\/products\/deploy-n8n-workflows-on-github-push-to-production-rest-api","provider":"N8N Commerce","version":"1.0","type":"link"}