GitHub CI/CD Service - Deploy To Shared Hosting With Github Actions
-
Create a GitHub workflow file;
mkdir .github mkdir .github/worflows touch main.yml
-
Inside the file paste the updated steps for Get Latest Code & Sync Files
name: ๐ Deploy website on push on: push: branches: [ main ] jobs: web-deploy: name: ๐ Deploy runs-on: ubuntu-latest steps: - name: ๐ Get latest code uses: actions/checkout@v2 - name: ๐ Sync files uses: burnett01/rsync-deployments@4.1 with: switches: -avzr --delete --exclude="" --include="" --filter="" path: / remote_path: ${{ secrets.REMOTE_PATH }} remote_host: ${{ secrets.REMOTE_HOST }} remote_port: ${{ secrets.REMOTE_PORT }} remote_user: ${{ secrets.REMOTE_USER }} remote_key: ${{ secrets.REMOTE_PRIVATE_KEY }}
-
Create a SSH keys on this folder
ssh-keygen -t rsa -b 4096 -C username@hostname
-
When it promted for Enter file in which to save the key change the name of the file, e.g:
repo-name
$ Generating public/private rsa key pair. $ Enter file in which to save the key (/Users/gunalirezqi/.ssh/id_rsa): repo-name $ Enter passphrase (empty for no passphrase): $ Enter same passphrase again:
-
Copy secret SSK key:
cat repo-name | pbcopy
-
Create a
REMOTE_PRIVATE_KEY
GitHub secret on your repo: Settings > Secrets > New secret and paste the secret SSH key -
Copy public SSK key
cat repo-name.pub | pbcopy
-
Create a deploy key on your GitHub repo: Settings > Deploy keys > Add deploy key and paste the public secret key
-
๐