Pulling from git via the Execute Command (or SSH) node

I am attempting to do something which may not be possible, but I thought I would ask. I am self-hosting n8n via docker and am building a workflow that when triggered by a webhook would execute a ‘git pull’ command on my server (whether that be localhost or my production server) in order to pull fresh copies of all workflows into n8n. It will be a selective pull - I’ll modify git and the command if/when I figure out how to successfully run ANY command :slight_smile:

My initial thought is to do this with the Execute Command node. What I’m failing to grasp is how to mount a volume in my docker-compose.yml file that would make my project directory visible to the command. In my n8n service config I’ve added a volume (found this on Stack Overflow) but I don’t know if it’s close or not to the right answer:

- ./var/run/docker.sock:/var/run/docker.sock

Here is just a current draft of the experiment.

When I change the command to ls, I get something as follows, which makes sense as it is the root level of the n8n container.

So I guess what I am asking is is there a way to allow the command node to reach into the root of my local development folder where the docker-compose.yml file resides so that I can pull from git?

If this is not possible/advisable, I was then thinking about running an SSH node instead. I can see how this would work in my production environment, but I don’t understand how/if it could work on my local developer instance on Docker in Windows.

Any ideas/suggestions would be welcome. Thank you!

Information on your n8n setup

  • n8n version: 0.221.2
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Windows 11

Hey @hndmn,

So you would want to mount a proper folder rather than a socket, On your host create a folder lets assume your username is hndmn we would make a folder under /home/hndmn/git then we would mount that folder to the container under /git so the mount option would be - /home/hndmn/git:/git once that is done start up the container and testing can begin.

To test I would make a file on the host so run something like touch /home/hndmn/git/test to make an empty file then using the execute command node in n8n run ls /git and see if it returns the file. If that has worked you are good to go.

1 Like

Excellent. I’ll give this a try soon and report back.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.