-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (47 loc) · 1.61 KB
/
dev-cd.yml
File metadata and controls
58 lines (47 loc) · 1.61 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Dev - CD (Deploy)
on:
workflow_run:
workflows: [ "Dev - CI (Build & Push)" ]
types: [ completed ]
permissions:
packages: read
jobs:
deploy:
# CI가 성공했을 때만 실행
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: [self-hosted]
# [설정] GitHub Environment의 'development' 변수들(32124 포트 등)을 사용
environment:
name: development
steps:
# CI에서 넘겨준 이미지 태그 파일 다운로드
- name: Download Image Tag Artifact
uses: actions/download-artifact@v4
with:
name: image-tag
github-token: ${{ secrets.ACTION_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Read Image Tag
id: get-tag
run: echo "IMAGE_TAG=$(head -n 1 image_tag.txt)" >> $GITHUB_OUTPUT
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.ACTION_TOKEN }}
- name: Pull latest image
run: docker pull ${{ steps.get-tag.outputs.IMAGE_TAG }}
- name: Clean up old container
run: |
docker rm -f ${{ secrets.CONTAINER_NAME }} || true
docker image prune -f
- name: Run New Container (Dev)
run: |
docker run -d \
--name ${{ secrets.CONTAINER_NAME }} \
--network ${{ secrets.NETWORK_NAME }} \
-p ${{ secrets.WEB_PORT }}:8080 \
-e SPRING_PROFILES_ACTIVE=dev \
-e TZ=Asia/Seoul \
${{ steps.get-tag.outputs.IMAGE_TAG }}