-
Notifications
You must be signed in to change notification settings - Fork 2
129 lines (111 loc) · 3.87 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
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
# github repository Actions 페이지에 나타낼 이름
name: CI/CD
# event trigger
on:
push:
branches:
- master
permissions:
contents: read
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
## jdk setting
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin' # https://github.com/actions/setup-java
## gradle caching
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
## create application-secret.yml
- name: make application-secret.yml
run: echo ${{ secrets.SECRET_YML }} | base64 --decode > ./src/main/resources/application-secret.yml
shell: bash
## create application-prod.yml
- name: make application-prod.yml
run: echo ${{ secrets.PROD_YML }} | base64 --decode > ./src/main/resources/application-prod.yml
shell: bash
# ## create application-prod.properties
# - name: make application-prod.properties
# if: contains(github.ref, 'main')
# run: |
# cd ./src/main/resources
# touch ./application-prod.properties
# echo "${{ secrets.PROPERTIES_PROD }}" > ./application-prod.properties
# shell: bash
# ## create firebase-key.json
# - name: create firebase key
# run: |
# cd ./src/main/resources
# ls -a .
# touch ./firebase-service-key.json
# echo "${{ secrets.FIREBASE_KEY }}" > ./firebase-service-key.json
# shell: bash
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build -x test
shell: bash
- name: Compile querydsl with Gradle
run: ./gradlew compilequerydsl
## docker build & push to production
- name: Docker build & push to prod
if: contains(github.ref, 'master')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile -t mkkim999/seesaw .
docker push mkkim999/seesaw
## deploy to production
- name: Deploy to prod
uses: appleboy/ssh-action@master
id: deploy-prod
if: contains(github.ref, 'master')
with:
host: ec2-3-36-172-10.ap-northeast-2.compute.amazonaws.com
username: ec2-user
key: ${{ secrets.PRIVATE_KEY }}
envs: GITHUB_SHA
script: |
sudo docker rm -f $(docker ps -qa)
sudo docker pull mkkim999/seesaw
docker-compose up -d
docker image prune -f
## time
# current-time:
# needs: CI-CD
# runs-on: ubuntu-latest
# steps:
# - name: Get Current Time
# uses: 1466587594/get-current-time@v2
# id: current-time
# with:
# format: YYYY-MM-DDTHH:mm:ss
# utcOffset: "+09:00" # 기준이 UTC이기 때문에 한국시간인 KST를 맞추기 위해 +9시간 추가
# - name: Print Current Time
# run: echo "Current Time=${{steps.current-time.outputs.formattedTime}}" # current-time 에서 지정한 포맷대로 현재 시간 출력
# shell: bash
## slack
# action-slack:
# needs: CI-CD
# runs-on: ubuntu-latest
# steps:
# - name: Slack Alarm
# uses: 8398a7/action-slack@v3
# with:
# status: ${{ job.status }}
# author_name: GitHub-Actions CI/CD
# fields: repo,message,commit,author,ref,job,took
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
# if: always() # Pick up events even if the job fails or is canceled.