n8n Configuration Guide 17: How to Add GitHub Credentials

10 months ago

A Pain Point

After going through the previous workflow series, I now have many workflows in my Lazy Cat n8n. This presents a problem:

How do I back up these workflow files? If I accidentally uninstall n8n and the data gets deleted, it would be devastating.

One way is to export the JSON file each time and save it locally.

But this method is quite cumbersome. I want to set up an n8n workflow to automatically sync all my workflows to GitHub with one click.

To achieve this functionality, the first step is to configure GitHub credentials. This guide will first explain how to do that.

https://appstore.lazycat.cloud/#/shop/detail/cloud.lazycat.app.n8n

How to Do It

Open n8n, and in the overview, you can see the Credentials section.

image.png

This contains all the credentials created by our previous workflows. They only need to be added once and can be reused later.

image.png

So, we just need to add a GitHub credential. Click the top-right corner, select 'New Credential' from the dropdown.

image.png

Search for 'git', and you will see these options:

image.png

If you select GitHub API: You need to enter a Personal Access Token.

If you select GitHub OAuth2 API: There will be a "Connect" or "Authorize" button. Clicking it will redirect you to GitHub for authorization.

You can simply understand it as: GitHub API is simpler to configure, while OAuth2 is more complex to configure but more secure.

Here, I choose GitHub API.

image.png

You can see that you need to enter your User and Access Token.

image.png

Open GitHub's Settings/Tokens page.

Click Generate new token (classic).

image.png

Check the repo permissions.

image.png

Generate the token and copy it.

image.png

Return to n8n, paste your token. The User is your GitHub username.

After saving, it will automatically connect. A success message will appear upon successful connection:

image.png

You can also see it on the Credentials page.

image.png

Let's verify if the connection is working properly.

Create a new Manual Trigger node, then add a node to list all repositories.

image.png

image.png

Search here and select your GitHub username.

image.png

Click Execute. You can see that my repository data has been successfully retrieved.

image.png

With the GitHub configuration in place, you can actually do many things. For example, daily CRUD operations can all be completed within n8n.

image.png

Author
天天