-
Notifications
You must be signed in to change notification settings - Fork 2
97 lines (84 loc) · 2.71 KB
/
cd_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
name: CD
on:
workflow_dispatch:
push:
branches: [ "develop" ]
paths-ignore:
- '**/*.md'
permissions:
contents: read
env:
DOCKER_REPOSITORY: sponus
APPLICATION_SECRET_PATH: ./api/src/main/resources
jobs:
deploy-with-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# Gradle caching
- name: Gradle Caching
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# Create application-secret.yaml
- name: Make application-secret.yml
run: |
mkdir -p $APPLICATION_SECRET_PATH
touch $APPLICATION_SECRET_PATH/application-secret.yml
echo "${{ secrets.APPLICATION_SECRET }}" > $APPLICATION_SECRET_PATH/application-secret.yml
## firebase-key 설정
- name: Set FCM
env:
DATA: ${{ secrets.FIREBASE_KEY }}
run: |
mkdir -p ./core/core-infra-firebase/src/main/resources/firebase
echo $DATA > ./core/core-infra-firebase/src/main/resources/firebase/firebase-key.json
# Grant execute permission for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Build with Gradle
- name: Build with Gradle
run: ./gradlew build -x test
# Docker Hub 로그인
- name: Docker Hub 로그인
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Docker build & Push
- name: Docker build & Push
run: |
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_REPOSITORY }} .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ env.DOCKER_REPOSITORY }}
# Send deploy.sh & docker-compose.yaml
- name: Send deploy.sh
uses: appleboy/scp-action@master
with:
username: ubuntu
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
port: 22
source: "./deploy/*"
target: "~"
# Deploy to Dev
- name: Deploy to Dev
uses: appleboy/ssh-action@master
with:
username: ubuntu
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
cd deploy
chmod 777 ./deploy.sh
./deploy.sh
docker image prune -f