Automate Multi-File Upload to GitHub with n8n REST API

Uploading multiple files to GitHub at once is cumbersome with native tools. This n8n workflow uses the GitHub REST API to push several files in a single commit, saving time and reducing errors in repository management.
httpRequest
set
manualTrigger
+1
Workflow Identifier: 1885
NODES in Use: Manual Trigger, Set, HTTP Request, Sticky Note

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow lets user push many files to a GitHub repo in just one commit.

It fixes the problem of GitHub nodes in n8n only uploading one file each time.

User gets a faster, simpler way to update multiple files without repeated manual steps.

The workflow calls GitHub API to find the latest commit and base tree.

Then it builds a new tree with many files and commits it with custom message.

Finally, it updates the branch reference to the new commit.

This speeds up multi-file updates and lowers errors from manual work.


How This Workflow Works (Inputs → Process → Outputs)

Inputs

  • GitHub username, repo name, branch name
  • GitHub Personal Access API Key with repo content write permission
  • Text content for multiple files to upload
  • Commit message text

Processing Steps

  • Get latest commit SHA from specified branch via API
  • Fetch full commit to retrieve base tree SHA
  • Create a new git tree with multiple files using their paths and content
  • Create a new commit referencing new tree and previous commit parent
  • Update branch reference to the new commit SHA

Output

  • GitHub branch updated with all new or modified files included in one commit

Who Should Use This Workflow

People who update several files at once in a GitHub repo.

Users who want to avoid manual uploads or multiple single-file commits.

Staff managing documentation, config files, or code needing batch updates.

Anyone wanting to speed up GitHub multi-file commits using n8n.


Tools and Services Used

  • n8n: Workflow automation platform running the process.
  • GitHub REST API: For retrieving latest commit, trees, creating commits, and updating refs.
  • GitHub Personal Access Token: Authentication and permission for API to read/write repo contents.

Beginner Step-by-Step: How to Use This Workflow in n8n for Production

1. Import Workflow

  1. Download the workflow file using the Download button on this page.
  2. Open n8n editor (could be cloud or self-host n8n instances).
  3. Click ‘Import from File’ and choose the downloaded workflow JSON file.

2. Configure Credentials

  1. Provide the GitHub Personal Access Token with repo content read/write scopes into the Set GitHub Info node.
  2. Enter your GitHub username, repo name, target branch, and commit message in the same node.

3. Update File Contents and Paths (if needed)

  1. Modify the File 1 and File 2 nodes with your needed file content.
  2. Change file paths in the Create new tree node if uploading files to other repo folders.

4. Test the Workflow

  1. Use the Manual Trigger node to manually start the workflow.
  2. Watch the output and logs to ensure the API calls succeed and files commit properly.

5. Activate for Production

  1. Switch workflow from draft to active in n8n to enable trigger-based or scheduled runs live.
  2. Integrate with other triggers or automate push on events as needed.

Customization Ideas

  • Add more files in Create new tree node by expanding the “tree” array with each extra file object’s path and content.
  • Change branch name in Set GitHub Info node to commit to different GitHub branches.
  • Replace static texts in File 1 and File 2 nodes with dynamic data from other API responses or workflows in n8n.

Common Problems and Fixes

Unauthorized 401 error from GitHub API

This happens when API Key is wrong or missing permissions.

Fix by checking that the GitHub Personal Access Token has repo content read/write scopes and is set correctly in Set GitHub Info node.

No such ref error updating branch

This means the branch name is incorrect or does not exist.

Confirm the branch name matches exactly with the repo branches and update Set GitHub Info node if needed.


Pre-Production Checklist

  • Check GitHub Personal Access Token includes write access for repo content.
  • Verify File 1 and File 2 nodes output correct file texts for commit.
  • Run the workflow with Manual Trigger and confirm successful API responses.
  • Backup important files in GitHub repository before running commits.

Deployment Guide

After testing, activate workflow in n8n for live use.

Trigger automatically from other workflows, CRON jobs, or events.

Watch executions in n8n UI for errors and fix nodes as needed.

Frequently Asked Questions

Yes, if the GitHub Personal Access Token has permissions to access private repositories.
Yes, because it makes multiple API requests for commits and trees, so monitor GitHub API rate limits.
Not directly; binary files must be base64 encoded and the API body updated accordingly to upload.
Check that the branch name in the Set GitHub Info node is exactly correct and exists in the GitHub repository.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free