Hi friends, In this article, I am going to write about how to deploy private github repo to server automatic . Only we will discuss about private git repository.
Most businesses adopt this strategy since it helps them secure their projects. Companies do not disclose their credentials to the public, it is a truth. They only favour secret work.
I often use the hostinger server. Similarly, you may follow to these instructions on any server.
To deploy private git repo to server, follow these steps one by one
1. Create FTP account
You have to go to hostinger dashboard and follow steps
- Goto to Files menu.
- Tap FTP Accounts in sub menu.
- Scroll down, Check Create a New FTP Account section.
- In Directory, You have to select directory to deploy your project. If you choose /public_html, It means you want deploy your project in root directory (Ex:- example.com).
- In my case, I am using test directory. So I will keep /public_html/test. It means you want deploy your project in test directory (Ex:- example.com/test).
- Choose Username.
- Make strong Password.
- Tap to Create button.
Congratulation ! You have created your FTP account successfully.
2. Create Secrets Variables in Github for FTP
- Goto to your private repository in github
- Tap Settings
- After, Tap Secrets and variables > Actions from left sidebar
- Tap New repository Secrets
- Now, create FTP_USERNAME key in name and paste FTP account username in Secret area.
- Again create FTP_PASSWORD key in name and paste FTP account password
3. Add yml script file in your private github repository
- Goto to your private repository in github
- Tap Actions button from top menu
- Click set up a workflow yourself link
- After, rename filename .config.yml and add following script
on:
push:
branches:
- main #Add your Branch name like as master/main
name: Deploy website on push
jobs:
web-deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Get latest code
uses: actions/checkout@v3
- name: Sync files
uses: SamKirkland/[email protected]
with:
server: Your_Server_IP_Address #Add Server IP
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
- Tap Commit changes button.
Congratulations ! You created Github Action CI/CD pipeline your private github repository to deploy github repository. Whenever you commit and push your project on github. It automatically deploy your project on website.