-
original tutorial
https://viandwi24.medium.com/github-actions-sederhana-untuk-testing-dan-deploy-ke-server-vps-a43976cd6f46#5752 -
make new linux user with limited access/no sudo
-
edit the yml workflow
name: CI-Deploy-serv3 on: push: branches: [ master ] workflow_dispatch: jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: '0' ref: 'master' - name: Deploy to Serv 3 Dwbz uses: appleboy/ssh-action@master with: host: ${{ secrets.HOST_GITHUBCI_SERV3DWBZ }} username: ${{ secrets.USERNAME_GITHUBCI_SERV3DWBZ }} key: ${{ secrets.SSHKEY_GITHUBCI_SERV3DWBZ }} port: 22 script: | bash /home/githubci/github-script -t=${{ secrets.GITHUB_TOKEN }}
-
script to be put on server to run GITHUB CI
File-name/home/githubci/github-script
#!/bin/bash for i in "$@"; do case $i in -t=*|--token=*) TOKEN="${i#*=}" shift # past argument=value ;; --default) DEFAULT=YES shift # past argument with no value ;; -*|--*) echo "Unknown option $i" exit 1 ;; *) ;; esac done cd /var/git/[repo].git git remote set-url origin https://[github username]:${TOKEN}@github.com/[github username]/[repo] git --work-tree=/var/www/webapps/[repo] pull origin master