]> littlesong.place Git - littlesongplace.git/commitdiff
Add production deploy job
authorChris Fulljames <christianfulljames@gmail.com>
Tue, 21 Jan 2025 12:17:04 +0000 (07:17 -0500)
committerChris Fulljames <christianfulljames@gmail.com>
Tue, 21 Jan 2025 12:17:04 +0000 (07:17 -0500)
.github/workflows/test-and-deploy.yml [moved from .github/workflows/deploy-test.yml with 67% similarity]

similarity index 67%
rename from .github/workflows/deploy-test.yml
rename to .github/workflows/test-and-deploy.yml
index 3f1f61f61c54c26e8ad891308a0abc8a200e0bb3..be3c2fcaf1ee6b44c9d559490d0134f016aef328 100644 (file)
@@ -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