Supporting Doc | YML file sample | Possible issue
1. Create an AWS or DigitalOcean Droplet: Set up your AWS or DigitalOcean droplet that will serve as your deployment server.
2. Access Droplet via Terminal: Use SSH to access your droplet through the terminal.
3. Generate SSH Key Pair: On the droplet, generate an SSH key pair by running the following command:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
4 Copy the Public Key: View the public key by running:
cat ~/.ssh/id_rsa.pub
Copy the displayed public key.
5. Add Public Key to GitHub: Add the copied public key to your GitHub account. Go to GitHub Settings > SSH and GPG keys, then add it in the SSH section. This step allows your repository to be cloned from GitHub to the server.
6. Edit Authorized Keys: Back on the server terminal, open the authorized_keys file with a text editor:
nano ~/.ssh/authorized_keys
Paste the copied public SSH key then press Control+X and accept changes.
7. Local Machine SSH Key: If your local machine doesn't already have a 4096-bit SSH key, create one by running:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
8. Copy Local Machine Secret Key: Copy the secret key from your local machine by running:
cat ~/.ssh/id_rsa
9. Add Secret Key to Repository: In your GitHub repository's Settings, go to Secrets and Variables > Secrets > Add Secret. Name it "SSHKEY" or a preferred name and paste the secret key.
Add 2 more secret one is "IP" another is "USER". Ip is the server public ip address and user for server user.
10. Add More Secrets: In the same section, add two more secrets: one for the droplet's IP address and another for the droplet access user.
11. Copy Local Machine Public Key: Run the following command on your local machine:
cat ~/.ssh/id_rsa.pub
Copy the displayed public key.
12. Edit Server's Authorized Keys: On the server, open the authorized_keys file for editing:
nano ~/.ssh/authorized_keys
Paste the copied local machine's public SSH key into this file.
13. Create deploy.yml File: Create a deploy.yml file in the .github/workflows/ directory of your GitHub repository with the following content: