Skip to content

Commit 4725905

Browse files
committed
fix(deploy): setup deploy workflow for prod and dev
1 parent ee85f50 commit 4725905

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

.github/workflows/deploy-dev.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Deploy to Dev VM
2+
3+
on:
4+
push:
5+
branches: ["dev"]
6+
workflow_dispatch: {}
7+
8+
concurrency:
9+
group: deploy-to-vm
10+
cancel-in-progress: true
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repo (optional)
17+
uses: actions/checkout@v4
18+
19+
# Start Tailscale on the runner using the official GitHub Action.
20+
# The action reads the client id / secret from env here (you said you already put them as secrets).
21+
- name: Start Tailscale
22+
uses: tailscale/github-action@v4
23+
with:
24+
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
25+
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
26+
tags: tag:ci
27+
28+
- name: SSH to VM and deploy
29+
run: |
30+
ssh -o "StrictHostKeyChecking no" ${{ secrets.INSTANCE_USER}}@${{ secrets.DEV_INSTANCE_TS_IP}} "
31+
cd ${{ secrets.PROJECT_PATH }}/frontend
32+
git checkout dev
33+
git fetch origin main
34+
git reset --hard origin/main
35+
docker compose stop frontend
36+
docker compose rm -f frontend
37+
docker compose build frontend
38+
docker compose up -d --no-deps --force-recreate frontend
39+
docker image prune -af
40+
docker container prune -f
41+
docker system prune -f
42+
"
43+
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy to VM via Tailscale
1+
name: Deploy to Prod VM
22

33
on:
44
push:
@@ -27,8 +27,9 @@ jobs:
2727

2828
- name: SSH to VM and deploy
2929
run: |
30-
ssh -o "StrictHostKeyChecking no" ${{ secrets.EC2_USER }}@${{ secrets.EC2_IP }} "
30+
ssh -o "StrictHostKeyChecking no" ${{ secrets.INSTANCE_USER}}@${{ secrets.PROD_INSTANCE_TS_IP}} "
3131
cd ${{ secrets.PROJECT_PATH }}/frontend
32+
git checkout main
3233
git fetch origin main
3334
git reset --hard origin/main
3435
docker compose stop frontend

0 commit comments

Comments
 (0)