-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (135 loc) · 5.16 KB
/
Copy pathdeploy_dev.yml
File metadata and controls
156 lines (135 loc) · 5.16 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Deploy Dev
on:
# push:
# branches:
# - cicd/eb
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Copy Secrets
uses: ./.github/actions/copy_secret
with:
profile: dev
oauth-secret: ${{ secrets.OAUTH_SECRET }}
s3-secret: ${{ secrets.S3_SECRET }}
dev-db-secret: ${{ secrets.EB_DEV_DB_SECRET }}
- name: Run MySQL image for test
run: docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=local_db mysql:8.0.31
- name: Build with Gradlew
env:
CHEFFI_DIRECTORY: ${{ secrets.CHEFFI_DIRECTORY }}
run: |
export CHEFFI_DIRECTORY=$CHEFFI_DIRECTORY
./gradlew clean build
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: build-artifacts
path: |
build/libs/*.jar
Dockerfile
.ebextensions
- name: Deployment Fail Notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: 'Deployment Fail Notification'
text: '서버 배포에 실패했습니다.'
fields: repo,message,commit,author,ref,workflow,job,took,pullRequest
mention: 'U05BT7J8YV8,U05BT2V4C58'
if_mention: failure
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_BACKEND_WEBHOOK_URL }} # required
if: failure()
deploy:
name: Deploy with ECR and EB
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: build-artifacts
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_EB_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_EB_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_EB_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ secrets.AWS_EB_IMAGE_TAG }}
# IMAGE_TAG: ${{ github.sha }}
AWS_REGION: ${{ secrets.AWS_EB_REGION }} # set this to your preferred AWS region, e.g. us-west-1
ECR_REPOSITORY: ${{ secrets.AWS_EB_ECR_REPOSITORY }} # set this to your Amazon ECR repository name
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to Elastic Beanstalk.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYYMMDD_HH-mm-ss
utcOffset: "+09:00"
- name: Copy Dockerrun.aws.json
env:
DOCKER_RUN_AWS: ${{ secrets.DOCKER_RUN_AWS }}
shell: bash
run: echo $DOCKER_RUN_AWS | base64 --decode > Dockerrun.aws.json
- name: Generate deployment package
run: |
mkdir -p deploy
cp -r .ebextensions deploy/.ebextensions
cp Dockerrun.aws.json deploy/Dockerrun.aws.json
cd deploy && zip -r deploy.zip .
- name: Beanstalk Deploy
uses: einaregilsson/beanstalk-deploy@v14
with:
aws_access_key: ${{ secrets.AWS_EB_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_EB_SECRET_ACCESS_KEY }}
application_name: cheffi-dev-eb
environment_name: Cheffi-dev-eb-env
version_label: cheffi-dev-${{ steps.current-time.outputs.formattedTime }}
region: ${{ secrets.AWS_EB_REGION }}
deployment_package: deploy/deploy.zip
wait_for_environment_recovery: 200
- name: Deployment Success Notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: 'Deployment Success Notification'
text: '서버가 성공적으로 배포되었습니다.'
fields: repo,message,commit,author,ref,workflow,job,took,pullRequest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: success()
- name: Deployment Fail Notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: 'Deployment Fail Notification'
text: '서버 배포에 실패했습니다.'
fields: repo,message,commit,author,ref,workflow,job,took,pullRequest
mention: 'U05BT7J8YV8,U05BT2V4C58'
if_mention: failure
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_BACKEND_WEBHOOK_URL }} # required
if: failure()