chore(fix): add new github actions #2
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: Auto Deploy in VPS after Push in Production | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy Django project | |
permissions: | |
deployments: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: 'actions/checkout@v2' | |
with: | |
ref: main | |
token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} | |
- name: Set up SSH Key and Deploy Django project | |
uses: appleboy/ssh-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }} | |
with: | |
host: ${{ secrets.VPS_IP }} | |
username: ${{ secrets.VPS_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
port: 22 | |
script: | | |
cd /var/www/2077-CMS/ | |
git pull origin main | |
python manage.py migrate | |
python manage.py collectstatic --no-input | |
sudo systemctl restart gunicorn | |
sudo systemctl restart nginx |