This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- main | |
name: Deploy website on push | |
jobs: | |
web-deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get latest code | |
uses: actions/[email protected] | |
# - name: Run command on server | |
# uses: D3rHase/[email protected] | |
# with: | |
# host: ${{ secrets.SSH_HOST }} | |
# user: ${{ secrets.SSH_USER }} | |
# private_key: ${{ secrets.SSH_PRIVATE_KEY }} | |
# command: | | |
# cd ${{ secrets.WORK_DIR }} | |
# git checkout main | |
# git pull | |
- name: Install ssh keys | |
run: | | |
install -m 600 -D /dev/null ~/.ssh/id_rsa | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts | |
- name: Connect and Pull | |
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && git checkout main && git pull && exit" | |
- name: Cleanup | |
run: rm -rf ~/.ssh |