Skip to content

Commit ec8d002

Browse files
authored
Update deploy.yml
1 parent 2745901 commit ec8d002

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

.github/workflows/deploy.yml

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,26 @@ jobs:
4444
ghcr.io/dmu-debugvisual/debugvisual-backend:latest
4545
ghcr.io/dmu-debugvisual/debugvisual-backend:${{ github.sha }}
4646
47+
48+
49+
4750
# EC2 배포 (익명 pull)
4851
- name: Deploy on EC2 (compose pull/up)
49-
env:
50-
HOST: ${{ secrets.EC2_HOST }}
51-
USER: ${{ secrets.EC2_USER }}
52-
run: |
53-
mkdir -p ~/.ssh
54-
echo "${{ secrets.EC2_KEY }}" > ~/.ssh/id_rsa
55-
sed -i 's/\r$//' ~/.ssh/id_rsa
56-
chmod 600 ~/.ssh/id_rsa
57-
ssh-keyscan -H "$HOST" >> ~/.ssh/known_hosts
52+
uses: appleboy/ssh-action@v1.2.0
53+
with:
54+
host: ${{ secrets.EC2_HOST }}
55+
username: ${{ secrets.EC2_USER }} # ec2-user
56+
key: ${{ secrets.EC2_KEY }} # PEM 전체 내용
57+
script: |
58+
set -e
59+
LOCK=/tmp/debugvisual.deploy.lock
60+
(
61+
flock -n 9 || { echo 'Another deploy is running. Skip.'; exit 0; }
62+
cd ~/apps/debugvisual
63+
docker logout ghcr.io || true # 익명 pull 강제
64+
docker compose pull --ignore-pull-failures backend
65+
docker compose up -d --wait --remove-orphans backend
66+
docker image prune -af || true
67+
curl -skI https://api.zivorp.com/healthz | head -n1
68+
) 9>$LOCK
5869
59-
# (선택) 배포 충돌 방지용 락
60-
ssh "$USER@$HOST" "bash -s" << 'EOSSH'
61-
set -e
62-
LOCK=/tmp/debugvisual.deploy.lock
63-
(
64-
flock -n 9 || { echo 'Another deploy is running. Skip.'; exit 0; }
65-
cd ~/apps/debugvisual
66-
docker logout ghcr.io || true # 익명 pull 강제
67-
docker compose pull --ignore-pull-failures backend
68-
docker compose up -d --wait --remove-orphans backend
69-
docker image prune -af || true
70-
curl -skI https://api.zivorp.com/healthz | head -n1
71-
) 9>$LOCK
72-
EOSSH

0 commit comments

Comments
 (0)