-
Notifications
You must be signed in to change notification settings - Fork 15
66 lines (60 loc) · 1.88 KB
/
cron-cicd.yaml
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
name: backend CI
on:
push:
paths:
- "cron/**"
pull_request:
paths:
- "cron/**"
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Make ssh file
run: |
mkdir -p ~/.ssh
echo '${{ secrets.SSH_CONFIG }}' | base64 -d > ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
- name: Checkout
uses: actions/checkout@v3
with:
submodule: true
- name: Update submodule
run: |
git submodule update --init config/
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: "17"
distribution: "corretto"
- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
run: |
cd cron
chmod +x gradlew
./gradlew jar
shell: bash
- name: Main S3에 업로드
if: ${{ github.ref == 'refs/heads/main' }}
run: |
cp cron/build/libs/cron-*.jar deploy-cron/build
mkdir -p deploy && cp deploy-cron/* deploy/
zip -r deploy.zip deploy
aws s3 cp deploy.zip s3://${{ secrets.AWS_S3_MAIN_BUCKET_NAME }}/deploy.zip
aws deploy create-deployment \
--application-name ${{ secrets.AWS_CODEDEPLOY_MAIN_APP_NAME }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ secrets.AWS_CODEDEPLOY_MAIN_GROUP_NAME }} \
--file-exists-behavior OVERWRITE \
--s3-location bucket=${{ secrets.AWS_S3_MAIN_BUCKET_NAME }},bundleType=zip,key=deploy.zip