-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (74 loc) · 3.34 KB
/
gradle.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
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
# Repo Action 페이지에 나타날 이름
name: Spring Boot & Gradle CI/CD
# Event Trigger
# master branch에 push 또는 pull request가 발생할 경우 동작
# branch 단위 외에도, tag나 cron 식 등을 사용할 수 있음
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Build
- name: Build with Gradle
run: ./gradlew clean build -x test
# 전송할 파일을 담을 디렉토리 생성
- name: Make Directory for deliver
run: mkdir deploy
# Jar 파일 Copy
- name: Copy Jar
run: cp ./build/libs/*.jar ./deploy/
# appspec.yml Copy
- name: Copy appspec
run: cp appspec.yml start.sh ./deploy/
# create .env file
- name: Create .env file
run: |
touch .env
echo "DB_URL=${{secrets.DB_URL}}" >> .env
echo "DB_USERNAME=${{secrets.DB_USERNAME}}" >> .env
echo "DB_PASSWORD=${{secrets.DB_PASSWORD}}" >> .env
echo "REDIS_HOST=${{secrets.REDIS_HOST}}" >> .env
echo "REDIS_PORT=${{secrets.REDIS_PORT}}" >> .env
echo "S3_ACCESS=${{secrets.S3_ACCESS}}" >> .env
echo "S3_SECRET=${{secrets.S3_SECRET}}" >> .env
echo "S3_BUCKET=${{secrets.S3_BUCKET}}" >> .env
echo "S3_REGION=${{secrets.S3_REGION}}" >> .env
echo "S3_STACK_AUTO=${{secrets.S3_STACK_AUTO}}" >> .env
echo "JWT_ISSUER=${{secrets.JWT_ISSUER}}" >> .env
echo "JWT_SECRET=${{secrets.JWT_SECRET}}" >> .env
echo "JWT_ACCESS_EXPIRATION=${{secrets.JWT_ACCESS_EXPIRATION}}" >> .env
echo "JWT_REFRESH_EXPIRATION=${{secrets.JWT_REFRESH_EXPIRATION}}" >> .env
echo "MAX_FILE=${{secrets.MAX_FILE}}" >> .env
echo "MAX_REQUEST=${{secrets.MAX_REQUEST}}" >> .env
echo "SSL_KEY_STORE=${{secrets.SSL_KEY_STORE}}" >> .env
echo "SSL_KEY_STORE_TYPE=${{secrets.SSL_KEY_STORE_TYPE}}" >> .env
echo "SSL_KEY_STORE_PASSWORD=${{secrets.SSL_KEY_STORE_PASSWORD}}" >> .env
# copy .env file
- name: copy .env file
run: cp .env ./deploy/
# 압축파일 형태로 전달
- name: Make zip file
run: zip -r -qq -j ./build.zip ./deploy
# S3 Bucket으로 copy
- name: Deliver to AWS S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: aws s3 cp --region ap-northeast-2 ./build.zip s3://amattang-bucket/server/build.zip
# Deploy
- name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: aws deploy create-deployment --application-name Amattang-deploy --deployment-group-name Github-Actions-Group --file-exists-behavior OVERWRITE --s3-location bucket=amattang-bucket,bundleType=zip,key=server/build.zip --region ap-northeast-2