forked from Insty-team/insty-backend-web
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (100 loc) · 3.07 KB
/
Copy pathdev.yml
File metadata and controls
121 lines (100 loc) · 3.07 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Insty(개발) 백엔드 CI/CD 파이프라인
on:
push:
branches:
- dev
paths-ignore:
- .github/workflows/main.yml
env:
ACTOR: ajroot5685
DOCKER_IMAGE_NAME: ghcr.io/ajroot5685/insty-backend-web
permissions:
contents: read
actions: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Build Spring Boot Application
run: |
chmod +x gradlew
./gradlew clean build -x test
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ env.ACTOR }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and Push Docker Image
run: |
docker build -t ${{ env.DOCKER_IMAGE_NAME }}:latest -f insty-api/Dockerfile insty-api
docker push ${{ env.DOCKER_IMAGE_NAME }}:latest
deploy:
needs: build
runs-on: [ self-hosted, insty-dev ]
steps:
- name: Login to GitHub Container Registry
run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u ${{ env.ACTOR }} --password-stdin
- name: Add Private Files
run: |
echo "${{ secrets.DEV_APPLICATION_ENV }}" | base64 --decode > .env
echo "${{ secrets.DEV_DOCKER_COMPOSE }}" | base64 --decode > docker-compose.yml
- name: Pull latest image and restart via Docker Compose
run: |
docker-compose pull backend
docker-compose down backend
docker-compose up -d backend
- name: Cleanup Docker and Cache
run: |
docker image prune -af || true
docker container prune -f || true
rm -rf ~/.gradle/caches
- name: Check ping
run: |
for i in {1..40}; do
RESPONSE=$(curl -s localhost:8080${{ secrets.HEALTH_CHECK_PATH }} || true)
if echo "$RESPONSE" | grep -q "true"; then
echo "✅ 애플리케이션 실행 완료"
exit 0
fi
sleep 5
done
echo "❌ 애플리케이션 실행 실패"
exit 1
notify:
needs:
- build
- deploy
runs-on: ubuntu-latest
if: success()
steps:
- name: Notify Slack
uses: 8398a7/action-slack@v3
with:
status: success
author_name: 백엔드-개발 파이프라인
fields: commit,author,ref,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
notify-failure:
needs:
- build
- deploy
runs-on: ubuntu-latest
if: failure()
steps:
- name: Notify Slack
uses: 8398a7/action-slack@v3
with:
status: failure
author_name: 백엔드-개발 파이프라인
fields: commit,author,ref,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}