add github action #1
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
name: Deploy to Remote Server | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code 🔍 | |
uses: actions/checkout@v3 | |
- name: Install SSH Key 🔐 | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
known_hosts: 'just-a-placeholder-so-we-dont-get-errors' | |
- name: Add known_hosts 🖥️ | |
run: ssh-keyscan -H ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts | |
- name: Upload with rsync 🔁 | |
run: rsync --delete -avz --exclude=".git" --exclude=".github" ./ {{secrets.SERVER_USER}}@${{ secrets.SERVER_IP }}:/bacaku | |
# Execute command ke VPS | |
- name: Execute Command ☣️ | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: ${{ secrets.SERVER_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: ${{ secrets.SERVER_PORT }} | |
script: | | |
python3 --version |