-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (83 loc) · 3.27 KB
/
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
95
96
97
name: 🚀 YELL:O Deploy
on:
push:
branches:
- main
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: 👉 JDK 17 zulu 버전을 세팅합니다.
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
cache: gradle
- name: 🐘 Gradle에 권한을 부여합니다.
run: chmod +x gradlew
shell: bash
## 시크릿 키 설정
- name: 🔐 application.yml 등 환경 변수를 세팅합니다.
run: |
cd ./src/main/resources
touch ./application.yml
echo "$APPLICATION" > ./application.yml
touch ./firebase_key.json
echo "$FIREBASE_JSON" > ./firebase_key.json
sed -i 's/#/"/g' ./firebase_key.json
touch ./google_client_secret.json
echo "$GOOGLE_CLIENT_SECRET" > ./google_client_secret.json
sed -i 's/#/"/g' ./google_client_secret.json
touch ./apple_client_secret.json
echo "$APPLE_CLIENT_SECRET" > ./apple_client_secret.json
sed -i 's/#/"/g' ./apple_client_secret.json
env:
APPLICATION: ${{ secrets.APPLICATION }}
FIREBASE_JSON: ${{ secrets.FIREBASE_JSON }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
APPLE_CLIENT_SECRET: ${{ secrets.APPLE_CLIENT_SECRET }}
shell: bash
- name: 🐘 Gradle로 빌드 실행
run: ./gradlew build
- name: 📦 배포를 진행하기 위한 .zip 파일을 생성합니다.
run: |
mkdir deploy
cp ./docker/docker-compose.blue.yml ./deploy/
cp ./docker/docker-compose.green.yml ./deploy/
cp ./appspec.yml ./deploy/
cp ./docker/Dockerfile ./deploy/
cp ./scripts/*.sh ./deploy/
cp ./build/libs/*.jar ./deploy/
zip -r -qq -j ./yello-build.zip ./deploy
shell: bash
- name: ⏳ AWS에 연결을 진행합니다.
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: 🪣 배포를 위해 S3에 프로젝트를 업로드합니다.
run: |
aws s3 cp \
--region ap-northeast-2 \
./yello-build.zip s3://yello-server-bucket
- name: 📡 CodeDeploy에 배포를 요청합니다.
run: aws deploy create-deployment --application-name yello-server-deploy
--deployment-config-name CodeDeployDefault.OneAtATime
--deployment-group-name yello-app
--s3-location bucket=yello-server-bucket,bundleType=zip,key=yello-build.zip
- name: 💡 배포 상태를 Slack을 통해 전송합니다.
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: general
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_MESSAGE: 배포에 ${{ job.status }} 했습니다.
SLACK_TITLE: 🚀 YELL:O 배포 결과 🚀
SLACK_USERNAME: Notification-Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_URL }}
if: always()