on: push: branches: - main workflow_dispatch: jobs: run_pull: name: run pull runs-on: ubuntu-latest environment: ssh_key steps: - name: install ssh keys # check this thread to understand why its needed: # https://stackoverflow.com/a/70447517 run: | install -m 600 -D /dev/null ~/.ssh/id_rsa echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa ssh-keyscan -p 222 -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts - name: connect and pull run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -p 222 "cd /home/fikyb-ssh/htdocs/fikyb.my.id && git checkout main && git pull && exit" - name: cleanup run: rm -rf ~/.ssh