Skip to content

Commit

Permalink
chore(fix): add new github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ndu committed Aug 17, 2024
1 parent c8bb72d commit 4f1407d
Showing 1 changed file with 26 additions and 31 deletions.
57 changes: 26 additions & 31 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
name: Auto Deploy in VPS after Push in Production
name: Deploy

on:
push:
branches:
- main
on: [push]

jobs:
deploy:
name: Deploy Django project
permissions:
deployments: write
build:

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
- uses: actions/checkout@v1

- name: Copy repository contents via scp
uses: appleboy/scp-action@master
env:
HOST: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: ${{ secrets.PORT }}
KEY: ${{ secrets.SSHKEY }}
with:
source: "."
target: "/var/www/2077-CMS"

- name: Executing remote command
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: ${{ secrets.PORT }}
KEY: ${{ secrets.SSHKEY }}
script: ls

0 comments on commit 4f1407d

Please sign in to comment.