diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index 2803eaf..4d878a9 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -7,6 +7,7 @@ on: jobs: test-api: + if: github.event.action != 'closed' runs-on: ubuntu-latest name: Test Cloud Services API @@ -32,6 +33,7 @@ jobs: pytest tests/ -v --tb=short test-web: + if: github.event.action != 'closed' runs-on: ubuntu-latest name: Test Web Client @@ -77,28 +79,26 @@ jobs: - name: Configure SSH run: | mkdir -p ~/.ssh - echo "${{ secrets.EC2_PEM_KEY }}" > ~/.ssh/CUloop.pem - chmod 600 ~/.ssh/CUloop.pem - printf "Host ec2\n HostName ${{ secrets.EC2_HOST }}\n User ${{ secrets.EC2_USER }}\n IdentityFile ~/.ssh/CUloop.pem\n StrictHostKeyChecking no\n" >> ~/.ssh/config + echo "${{ secrets.EC2_PEM_KEY }}" > ~/.ssh/CULoop.pem + chmod 600 ~/.ssh/CULoop.pem + printf "Host ec2\n HostName ${{ secrets.EC2_HOST }}\n User ${{ secrets.EC2_USER }}\n IdentityFile ~/.ssh/CULoop.pem\n StrictHostKeyChecking no\n" >> ~/.ssh/config - name: Deploy to EC2 run: | ssh ec2 << 'EOF' - cd /home/ubuntu/electrical-gui - git pull origin main - - # Deploy API - cd cloud-services - python -m pip install --upgrade pip - pip install -r requirements.txt - pm2 restart cloud-api || pm2 start "uvicorn src.main:app --host 0.0.0.0 --port 8080" --name cloud-api + cd ~ - # Deploy Web Client - cd ../web-client + # Update web client + cd web-client + git pull origin main npm ci npm run build - pm2 restart web-client || pm2 start "npm run preview" --name web-client + sudo systemctl restart frontend - # Save PM2 configuration - pm2 save - EOF + # Update API + cd ../cloud-services + git pull origin main + python -m pip install --upgrade pip + pip install -r requirements.txt + sudo systemctl restart backend + EOF \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5203b05 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "web-client" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/cloud-services b/cloud-services index 16debb0..24d9e60 160000 --- a/cloud-services +++ b/cloud-services @@ -1 +1 @@ -Subproject commit 16debb0ac96bfa4b3ec82066141e912839bfed4c +Subproject commit 24d9e60a66c02f87174e24c2b8b147d75992988b diff --git a/web-client b/web-client index e5d8e44..1a01344 160000 --- a/web-client +++ b/web-client @@ -1 +1 @@ -Subproject commit e5d8e442f45738fea20da908b9c6b1c2a281605d +Subproject commit 1a013443c46c05c22e06d2f5c88557c37a5e3279