-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (46 loc) · 1.8 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
name: Build and Deploy to EC2
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
defaults:
run:
shell: bash
env:
AWS_S3_BUCKET: 4k-backend-bucket
AWS_CODE_DEPLOY_APPLICATION: 4K-Backend-CD
AWS_CODE_DEPLOY_GROUP: 4K-Backend-CD-Group
jobs:
deploy:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: Run chmod to make gradlew executable
run: chmod +x ./BackEnd/gradlew
- name: Build Project and Test
working-directory: BackEnd
run: ./gradlew build test
- name: Setup MySQL
uses: mirromutth/mysql-action@v1.1
with:
mysql database: 'ringodb'
mysql user: ${MYSQL_DATABASE_USERNAME}
mysql password: ${MYSQL_DATABASE_PASSWORD}
- name: Configure AWS credential
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ap-northeast-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Upload to S3
working-directory: ./BackEnd
run: aws deploy push --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://${{ env.AWS_S3_BUCKET }}/4K-Backend-EC2/$GITHUB_SHA.zip --source .
- name: Code Deploy to EC2
working-directory: ./BackEnd
run: aws deploy create-deployment --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }} --s3-location bucket=${{ env.AWS_S3_BUCKET }},key=4K-Backend-EC2/$GITHUB_SHA.zip,bundleType=zip