Skip to content

Merge pull request #114 from kakao-tech-campus-2nd-step3/weekly/11 #58

Merge pull request #114 from kakao-tech-campus-2nd-step3/weekly/11

Merge pull request #114 from kakao-tech-campus-2nd-step3/weekly/11 #58

name: master ๋ฐ weekly ๋ธŒ๋žœ์น˜ merge ์‹œ CI/CD ํŒŒ์ดํ”„๋ผ์ธ
on:
push:
branches:
- 'master'
- 'weekly/**'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: ํ”„๋กœ์ ํŠธ ์ฝ”๋“œ๋ฅผ CI ์„œ๋ฒ„๋กœ ์˜ฎ๊ฒจ์˜ค๊ธฐ
uses: actions/checkout@v4
- name: Gradle ์บ์‹œ ์„ค์ •
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: JDK 21 ์„ค์น˜
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '21'
- name: FCM ์„œ๋น„์Šค ๊ณ„์ • ํ‚ค ํŒŒ์ผ ์ƒ์„ฑ
run: |
echo '${{ secrets.FCM_SERVICE_ACCOUNT_KEY }}' > ./src/main/resources/everymoment.json
- name: AWS S3 ๊ด€๋ จ ์ •๋ณด๋ฅผ ์„ค์ • ํŒŒ์ผ์— ์ฃผ์ž…
uses: microsoft/variable-substitution@v1
with:
files: ./src/main/resources/application-prod.yml
env:
spring.datasource.url: ${{ secrets.RDS_URL }}
spring.datasource.username: ${{ secrets.RDS_USERNAME }}
spring.datasource.password: ${{ secrets.RDS_PASSWORD }}
aws.s3.bucket: ${{ secrets.AWS_S3_BUCKET }}
aws.s3.accessKey: ${{ secrets.AWS_S3_ACCESS_KEY }}
aws.s3.secretKey: ${{ secrets.AWS_S3_SECRET_KEY }}
jwt.secret: ${{ secrets.JWT_SECRET }}
- name: ๋นŒ๋“œ๋กœ ํ…Œ์ŠคํŠธ ์ˆ˜ํ–‰ ๋ฐ Jar ํŒŒ์ผ ์ƒ์„ฑ
run: |
chmod +x ./gradlew
./gradlew clean build --build-cache
- run: mv build/libs/*SNAPSHOT.jar ./app.jar
- name: ์ƒ์„ฑ๋œ Jar ํŒŒ์ผ EC2 ์„œ๋ฒ„๋กœ ์ „์†กํ•˜๊ธฐ
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
script_stop: true
overwrite: true
source: app.jar
target: /home/ubuntu/project
- name: EC2 ์„œ๋ฒ„์— ์ ‘์†ํ•˜๊ธฐ(SSH) ๋ฐ ์Šคํ”„๋ง ์„œ๋ฒ„ ์‹คํ–‰
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
script_stop: true
script: |
cd ./project
sudo fuser -k -n tcp 8080 || true
nohup java -Duser.timezone=Asia/Seoul -jar app.jar > ./output.log 2>&1 &