-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (88 loc) · 3.77 KB
/
deploy.yml
File metadata and controls
107 lines (88 loc) · 3.77 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
env:
RESOURCE_PATH: ./api/src/main/resources/application.yml
INTEGRATION_PATH: ./integration/src/main/resources/integration.yml
PROJECT_NAME: codelap_project
BUCKET_NAME: codelap
CODE_DEPLOY_APP_NAME: codelap
DEPLOYMENT_GROUP_NAME: codelap
REST_DOCS_BUCKET_NAME: codelapdocs
SWEAGER_BUCKET_NAME: codelap-swagger
REST_DOCS: ./api/build/docs/asciidoc/index.html
SWAGGER_DOCS_HTML: ./api/build/swagger-ui-convert/index.html
SWAGGER_DOCS_JS: ./api/build/swagger-ui-convert/swagger-spec.js
DB_PASSWORD: root
name: Merge
on:
pull_request:
branches: [ "main" ]
types:
- closed
permissions:
contents: read
jobs:
Deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Set up MySQL
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE codelaptest;' -uroot -proot
- name: "application.yml Set"
uses: microsoft/variable-substitution@v1
with:
files: ${{ env.RESOURCE_PATH }}
env:
spring.datasource.url: ${{ secrets.RDB_URL }}
spring.datasource.username: ${{ secrets.RDB_USER_NAME }}
spring.datasource.password: ${{ secrets.RDB_PASSWORD }}
oauth2.frontUri: ${{ secrets.OAUTH2_FRONT_URI }}
spring.security.oauth2.client.registration.github.client-id: ${{ secrets.OAUTH2_CLIENT_ID }}
spring.security.oauth2.client.registration.github.client-secret: ${{ secrets.OAUTH2_CLIENT_SECRET }}
spring.security.oauth2.client.registration.github.redirect-uri: ${{ secrets.OAUTH2_REDIRECT_URI }}
- name: "integration.yml Set"
uses: microsoft/variable-substitution@v1
with:
files: ${{ env.INTEGRATION_PATH }}
env:
discord.webhook-url: ${{ secrets.DISCORD_URL }}
discord.username: Log
discord.avatar-url: ${{ secrets.DISCORD_AVATAR }}
aws.access-key: ${{ secrets.CLOUD_AWS_CREDENTIALS_ACCESS_KEY }}
aws.secret-key: ${{ secrets.CLOUD_AWS_CREDENTIALS_SECRET_KEY }}
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
- name: Build with Gradle
run: ./gradlew clean :api:buildNeeded --stacktrace
shell: bash
- name: Generate Swagger UI
run: ./gradlew api:openapi3 -x test api:generateSwaggerUIConvert
shell: bash
- name: Generate RestDocs
run: ./gradlew api:asciidoctor -x test
shell: bash
- name: Make zip file
run: zip -r ./$GITHUB_SHA.zip .
shell: bash
- 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: Server Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip
- name: RestDocs Upload to S3
run: aws s3 cp --region ap-northeast-2 $REST_DOCS s3://$REST_DOCS_BUCKET_NAME/index.html
- name: Swagger Html Upload to S3
run: aws s3 cp --region ap-northeast-2 $SWAGGER_DOCS_HTML s3://$SWEAGER_BUCKET_NAME/index.html
- name: Swagger Js Upload to S3
run: aws s3 cp --region ap-northeast-2 $SWAGGER_DOCS_JS s3://$SWEAGER_BUCKET_NAME/swagger-spec.js
- name: Code Deploy
run: aws deploy create-deployment --application-name $CODE_DEPLOY_APP_NAME --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name $DEPLOYMENT_GROUP_NAME --s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip