-
Notifications
You must be signed in to change notification settings - Fork 2
42 lines (34 loc) · 1.17 KB
/
cd.yml
File metadata and controls
42 lines (34 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: CD
on:
push:
branches: [ "main" ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to EC2 (git pull -> docker compose build & up)
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.CD_EC2_HOST }}
username: ${{ secrets.CD_EC2_USER }}
key: ${{ secrets.CD_EC2_SSH_PRIVATE_KEY }}
port: ${{ secrets.CD_EC2_SSH_PORT }}
script: |
set -e
cd ${{ secrets.CD_EC2_APP_DIR }}
git fetch --all
git reset --hard origin/main
docker compose -f docker-compose-dev.yml --env-file .env down || true
docker compose -f docker-compose-dev.yml --env-file .env up -d --build --force-recreate --remove-orphans
# API가 뜰 때까지 최대 60초 대기
for i in {1..30}; do
if curl -fsS http://127.0.0.1:8080/v3/api-docs > /dev/null; then
echo "API is up"
exit 0
fi
sleep 2
done
echo "API did not become ready"
docker ps -a
docker logs timeto-app-dev --tail 200
exit 1