@@ -2,12 +2,21 @@ name: Deploy the frontend
22on :
33 push :
44 branches : [main]
5+ paths :
6+ - ' apps/collabydraw/**'
7+ - ' packages/**'
8+ - ' .github/workflows/cd_frontend.yml'
59jobs :
6- build :
10+ build-and-deploy :
711 runs-on : ubuntu-latest
812 steps :
913 - name : Checkout the code
1014 uses : actions/checkout@v4
15+ with :
16+ fetch-depth : 2
17+
18+ - name : Set up Docker Buildx
19+ uses : docker/setup-buildx-action@v3
1120
1221 - name : Docker login
1322 uses : docker/login-action@v3
@@ -25,14 +34,38 @@ jobs:
2534 echo "Error: JWT_SECRET secret is not set"
2635 exit 1
2736 fi
37+ $secrets_valid
2838
29- - name : Build and push
39+ - name : Build and push Frontend
3040 uses : docker/build-push-action@v5
3141 with :
3242 context : .
3343 file : ./docker/Dockerfile.frontend
44+ provenance : false
3445 build-args : |
3546 DATABASE_URL=${{ secrets.DATABASE_URL }}
3647 JWT_SECRET=${{ secrets.JWT_SECRET }}
48+ WEBSOCKET_URL=${{ secrets.WEBSOCKET_URL }}
3749 push : true
38- tags : coderomm/collabydraw:${{ github.sha }}
50+ tags : |
51+ coderomm/collabydraw:latest
52+ coderomm/collabydraw:${{ github.sha }}
53+
54+ - name : Deploy to VM
55+ uses : appleboy/ssh-action@master
56+ with :
57+ host : ${{ secrets.VM_HOST }}
58+ username : ${{ secrets.VM_USERNAME }}
59+ key : ${{ secrets.SSH_PRIVATE_KEY }}
60+ script : |
61+ docker pull coderomm/collabydraw:${{ github.sha }}
62+ docker stop collabydraw-frontend || true
63+ docker rm collabydraw-frontend || true
64+ docker run -d \
65+ --name collabydraw-frontend \
66+ -p 3000:3000 \
67+ -e DATABASE_URL=${{ secrets.DATABASE_URL }} \
68+ -e JWT_SECRET=${{ secrets.JWT_SECRET }} \
69+ -e WEBSOCKET_URL=${{ secrets.WEBSOCKET_URL }} \
70+ coderomm/collabydraw:${{ github.sha }}
71+
0 commit comments