How to deploy Node.js to our server through GitHub deploy key?

Programming, error messages and sample code > Node.js
A GitHub deploy key is an SSH key that grants access to a single repository. It is primarily used to automate the launching of projects from GitHub to your server, such as in production environments or CI/CD pipelines. This article will introduce how to deploy a Node.js application to our server using a GitHub deploy key.
 
1. Generate SSH key locally
  • Open command prompt and run the command below:
ssh-keygen -t ed25519 -C "deploy-key-example"
 
  • You will get 2 files in the default folder(C:\Users\xxx): test and test.pub(you can custom file name when generating it, 'test' is the private key needed to upload to our server, 'test.pub' is the public key needed to be uploaded to GitHub).
2. Go to GitHub > find your project's repository > Settings > Deploy keys > Add deploy key
 
 
3. Copy the content of public key(test.pub) to the "Key" field and add it(select "Allow write access" only if the key needs permission to push code to the repository; otherwise, leave it unchecked for read-only access).
 
 
4. Go to our control panel > Websites > Github Deploy
 
 
5. Now you will see some options:
  • Git Branch(optional, default branch is usually main or master)
  • Github Repository URL(required)
  • Deploy key(required)
  • Select deploy key(required, choose the private key file(test) generated at step1)
  • Passphrase (optional, needed only if your key has a passphrase):
  • Build Command (optional, automatically detected if left blank for most frameworks)
  • Start Command (optional, automatically detected if left blank)
 
6. Click "Deploy Now" and you will see the deployment progress as shown in this image