My name is CiCd
I can help you deploy quickly your code hosted on github to your vps using your ssh creds. It's easy like deploy and refresh to see changes
This is not a full fledged CiCd tools. This is a simple CiCd that can be used to deploy a simple application to a server using ssh.
Code is not tested before deployment. You may be aware of the consequences when pushing to the main branch.
Of course, you can add more steps to the github action to test your code before deploying it.
Ex:
name: Deploy to VPS from main branch on push
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Deploy to VPS
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USERNAME }}
password: ${{ secrets.VPS_PASSWORD }}
script: | # This is the script that will be executed on the server in that order
cd /var/www/cicd
git pull
git checkout main
git reset --hard origin/main
# Your script start below
# Your script end here
echo "Deployed at $(date)"
When you push to the main branch, the github action will be triggered. It will checkout the code and run the script in the server using ssh with the credentials you provided on the github secrets.
Note due to github freee plan limitations, we must set secrets for each private repo we create. If you have multiple private repos, you must set the secrets for each repo. Organization wide secrets are not available for free plan. Only for paid plans.
If target repos are public, we can use organization wide secrets.
When using this tiny cicd, please follow:
Note this is only suitable development workflow. For production, wait a bit !
You should know that you're responsible for the code you push to the main branch. This is not a full fledged CiCd. This is a simple CiCd that can be used to deploy a simple application to a server using ssh.
Script your provided will be executed in the server with the power of the user you provided. So be careful when writing the script what user creds you provide.
Code is not tested before deployment. You may be aware of the consequences when pushing to the main branch.
Code is intellectual property of Selys-Africa
appleboy/ssh-action is used to run remote ssh