-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ndu
committed
Aug 17, 2024
1 parent
c8bb72d
commit 4f1407d
Showing
1 changed file
with
26 additions
and
31 deletions.
There are no files selected for viewing
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
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 |