Github Node

Hi n8n folks!

Hope everyone had a nice holiday!

I am having a lot of trouble with getting a file from Github using the github node.

In particular, the “file path” is giving me difficulty.

I cannot find an example of what this is supposed to look like, and I’m not having any luck trying all kinds of options.

Name, URL, some paths, full? paths…

In particular, I’m looking to get the source code.zip from a release version, but any hints will do…

Anyone have any examples that work?

Even looking at the JSON from a get release has not yielded the answer.

Thanks!

Hi @wsargent, here’s a very quick example:

This downloads the file n8n/n8n-logo.png at master · n8n-io/n8n · GitHub. Repository Owner would be n8n-io, Repository Name = n8n and the File Path is assets/n8n-logo.png in this example.

Example Workflow
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "file",
        "operation": "get",
        "owner": "n8n-io",
        "repository": "n8n",
        "filePath": "assets/n8n-logo.png"
      },
      "name": "GitHub",
      "type": "n8n-nodes-base.github",
      "typeVersion": 1,
      "position": [
        460,
        300
      ],
      "credentials": {
        "githubOAuth2Api": {
          "id": "71",
          "name": "Github account"
        }
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "GitHub",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Fetching release files is a bit trickier as there are typically multiple files per release. So you would first need to fetch a release, e.g. like so:

Example Workflow
{
    "nodes": [
      {
        "parameters": {},
        "name": "Start",
        "type": "n8n-nodes-base.start",
        "typeVersion": 1,
        "position": [
          240,
          300
        ]
      },
      {
        "parameters": {
          "authentication": "oAuth2",
          "resource": "release",
          "operation": "getAll",
          "owner": "bunqCommunity",
          "repository": "bunqDesktop",
          "limit": 1
        },
        "name": "GitHub",
        "type": "n8n-nodes-base.github",
        "typeVersion": 1,
        "position": [
          660,
          440
        ],
        "credentials": {
          "githubOAuth2Api": {
            "id": "71",
            "name": "Github account"
          }
        }
      },
      {
        "parameters": {
          "url": "https://api.github.com/repos/bunqCommunity/bunqDesktop/releases/26039809/assets",
          "options": {
            "splitIntoItems": true
          }
        },
        "name": "HTTP Request",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 1,
        "position": [
          880,
          440
        ]
      }
    ],
    "connections": {
      "Start": {
        "main": [
          [
            {
              "node": "GitHub",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "GitHub": {
        "main": [
          [
            {
              "node": "HTTP Request",
              "type": "main",
              "index": 0
            }
          ]
        ]
      }
    }
  }

You would then need to filter for the file you’re interested in and download it using the browser_download_url returned by the last node in the example above.

Hope this helps!

1 Like

Thanks @MutedJam! This is a huge help, and I was able to get it going and climb back out of the rabbit hole!

1 Like