-
Notifications
You must be signed in to change notification settings - Fork 2
113 lines (104 loc) · 4.03 KB
/
awsec2.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: OPERATION EC2
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
tags:
description: 'Test scenario tags'
push:
branches:
- main
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Gradle 빌드 캐싱
id: gradle-cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Properties 파일에 mongodb uri 주입
uses: christian-draeger/[email protected]
with:
path: './src/main/resources/application-prod.properties'
property: 'spring.data.mongodb.uri'
value: ${{ secrets.SPRING_DATA_MONGODB_URI }}
- name: Properties 파일에 mongodb 세팅 주입
uses: christian-draeger/[email protected]
with:
path: './src/main/resources/application-prod.properties'
property: 'spring.data.mongodb.auto-index-creation'
value: 'true'
- name: Properties 파일에 jwt secret 주입
uses: christian-draeger/[email protected]
with:
path: './src/main/resources/application-prod.properties'
property: 'jwt.secret'
value: ${{ secrets.JWT_SECRET }}
- name: Properties 파일에 AWS_ACCESS_KEY 주입
uses: christian-draeger/[email protected]
with:
path: './src/main/resources/application-prod.properties'
property: 'cloud.aws.credentials.accessKey'
value: ${{ secrets.AWS_ACCESS_KEY_ID }}
- name: Properties 파일에 AWS_SECRET_ACCESS_KEY 주입
uses: christian-draeger/[email protected]
with:
path: './src/main/resources/application-prod.properties'
property: 'cloud.aws.credentials.secretKey'
value: ${{ secrets.INJECT_SECRET }}
- name: Properties 파일에 원하는 프로파일 명 주입
uses: christian-draeger/[email protected]
with:
path: './src/main/resources/application.properties'
property: 'spring.profiles.active'
value: 'prod'
- name: Build with Gradle test
run: ./gradlew test
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
if: always()
with:
files: build/test-results/**/*.xml
check_name: '[unit-test] Results'
- name: Build with Gradle copyDocument
run: ./gradlew copyDocument
- name: Build with Gradle
run: ./gradlew build
- name: cp
run: cp appspec.yml ./build/libs/appspec.yml && cp deploy.sh ./build/libs/deploy.sh
shell: bash
- name: Make zip file
run: zip -qq -r ./$GITHUB_SHA.zip .
shell: bash
working-directory: ./build/libs
- name: Configure AWS credentials
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
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://memealabucket/$GITHUB_SHA.zip
working-directory: ./build/libs
- name: Code Deploy
run: aws deploy create-deployment --application-name meme_ala --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name meme_ala_security_group --s3-location bucket=memealabucket,bundleType=zip,key=$GITHUB_SHA.zip