From 4f1407d99ee4363dfcd3fd6eb51095c9e1139891 Mon Sep 17 00:00:00 2001 From: ndu Date: Sat, 17 Aug 2024 14:16:21 +0100 Subject: [PATCH] chore(fix): add new github actions --- .github/workflows/deploy.yml | 57 ++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 70713b1..ea54105 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 \ No newline at end of file + - 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 \ No newline at end of file