-
Notifications
You must be signed in to change notification settings - Fork 2
94 lines (81 loc) · 2.77 KB
/
dev-deploy.yml
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
name: connectdog CICD(deploy)
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@v3
# JDK를 17 버전으로 세팅
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# Gradle 캐싱-> 빌드 속도 UP
- name: Gradle caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# application-jwt.yml 파일 생성
- name: make application-jwt.yml
run: |
cd ./src/main/resources
touch ./application-jwt.yml
echo "${{ secrets.APPLICATION_JWT_YML }}" > ./application-jwt.yml
shell: bash
# application-dev.yml 파일 생성
- name: make application-dev.yml
run: |
cd ./src/main/resources
touch ./application-dev.yml
echo "${{ secrets.APPLICATION_DEV_YML }}" > ./application-dev.yml
shell: bash
# ./gradlew 권한 설정
- name: ./gradlew 권한 설정
run: chmod +x ./gradlew
# Gradle build (Test 제외)
- name: Build with Gradle
run: ./gradlew build -x test
# AWS에 연결
- name: Connect to AWS
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
# 빌드파일을 ZIP 파일로 생성
- name: Make zip file
run: |
mkdir deploy
cp ./docker-compose.blue.yml ./deploy/
cp ./docker-compose.green.yml ./deploy/
cp ./appspec.yml ./deploy/
cp ./Dockerfile ./deploy/
cp ./scripts/deploy.sh ./deploy/
cp ./build/libs/*.jar ./deploy/
zip -r -qq -j ./connectdog-build.zip ./deploy
# S3에 zip 파일 업로드
- name: Upload to S3
run: |
aws s3 cp \
--region ap-northeast-2 \
./connectdog-build.zip s3://connectdog-bucket
# CodeDeploy에 배포 요청
- name: Code Deploy Deployment Request
run: |
aws deploy create-deployment --application-name ConnectDog \
--deployment-config-name CodeDeployDefault.OneAtATime \
--deployment-group-name ConnectDog \
--s3-location bucket=connectdog-bucket,bundleType=zip,key=connectdog-build.zip