Skip to content

Commit 35c5428

Browse files
committed
Infra: 자동화 배포 워크 플로우 파일 반영
- 기존 파일 이름 : /workflows/deploy.yml -> 변경 : /workflows/backend-cd.yml - jobs.deploy 작업 일부 수정
1 parent 1e1b690 commit 35c5428

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

.github/workflows/deploy.yml renamed to .github/workflows/backend-cd.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: deploy
1+
name: backend-cd
22
on:
33
push:
44
paths:
@@ -61,7 +61,7 @@ jobs:
6161
- name: set lower case owner name
6262
run: |
6363
echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV}
64-
64+
6565
6666
- name: 빌드 앤 푸시
6767
uses: docker/build-push-action@v3
@@ -71,12 +71,18 @@ jobs:
7171
tags: |
7272
ghcr.io/${{ env.OWNER_LC }}/${{ env.DOCKER_IMAGE_NAME }}:${{ needs.makeTagAndRelease.outputs.tag_name }},
7373
ghcr.io/${{ env.OWNER_LC }}/${{ env.DOCKER_IMAGE_NAME }}:latest
74-
75-
74+
75+
7676
deploy:
7777
runs-on: ubuntu-latest
7878
needs: [ buildImageAndPush ]
79+
env:
80+
OWNER: ${{ github.repository_owner }}
7981
steps:
82+
- name: set lower case owner name
83+
run: |
84+
echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV}
85+
8086
- name: AWS SSM Send-Command
8187
uses: peterkimzz/aws-ssm-send-command@master
8288
id: ssm
@@ -88,7 +94,18 @@ jobs:
8894
working-directory: /
8995
comment: Deploy
9096
command: |
97+
# 0. env 변수 확인
98+
echo "OWNER_LC = ${{ env.OWNER_LC }}"
99+
100+
# 1. 최신 이미지 pull
91101
docker pull ghcr.io/${{ env.OWNER_LC }}/catfe-backend:latest
102+
103+
# 2. 기존 컨테이너 종료 및 제거
92104
docker stop catfe-backend 2>/dev/null
93105
docker rm catfe-backend 2>/dev/null
94-
docker run -d --name catfe-backend -p 8080:8080 ghcr.io/${{ env.OWNER_LC }}/catfe-backend:latest
106+
107+
# 3. 새로운 컨테이너 실행
108+
docker run -d --name catfe-backend -p 8080:8080 ghcr.io/${{ env.OWNER_LC }}/catfe-backend:latest
109+
110+
# 4. dangling 이미지 삭제
111+
docker rmi $(docker images -f "dangling=true" -q)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ out/
4040
db_dev.mv.db
4141
db_dev.trace.db
4242
.env
43+
.env.*
4344

4445
### Terraform ###
4546
/infra/terraform/.terraform

0 commit comments

Comments
 (0)