From 8fc6ab105504f479d149d9739142d1a4d3dca6c1 Mon Sep 17 00:00:00 2001 From: Chris Fulljames Date: Tue, 21 Jan 2025 07:17:04 -0500 Subject: [PATCH] Add production deploy job --- .../{deploy-test.yml => test-and-deploy.yml} | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) rename .github/workflows/{deploy-test.yml => test-and-deploy.yml} (67%) diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/test-and-deploy.yml similarity index 67% rename from .github/workflows/deploy-test.yml rename to .github/workflows/test-and-deploy.yml index 3f1f61f..be3c2fc 100644 --- a/.github/workflows/deploy-test.yml +++ b/.github/workflows/test-and-deploy.yml @@ -1,4 +1,4 @@ -name: Deploy Test +name: Test and Deploy on: [push, workflow_dispatch] jobs: run-offline-tests: @@ -61,7 +61,7 @@ jobs: run-online-tests: runs-on: ubuntu-latest - needs: [run-offline-tests, deploy-test-instance] + needs: deploy-test-instance steps: - uses: actions/checkout@v1 @@ -80,3 +80,35 @@ jobs: run: | pytest test_online.py + deploy-prod-instance: + needs: run-online-tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: Copy repo contents to server via SCP + uses: appleboy/scp-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + port: ${{ secrets.PORT }} + key: ${{ secrets.SSHKEY }} + source: "." + target: "/var/www/littlesongplace" + + - name: Run production server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + USERNAME: ${{ secrets.USERNAME }} + PORT: ${{ secrets.PORT }} + KEY: ${{ secrets.SSHKEY }} + script: | + # Setup venv + cd /var/www/littlesongplace + python3 -m venv venv + . venv/bin/activate + pip install -r requirements.txt + + # Restart service + sudo systemctl restart littlesongplace.service -- 2.39.5