Skip to content

Merge remote-tracking branch 'origin/main' into qa #49

Merge remote-tracking branch 'origin/main' into qa

Merge remote-tracking branch 'origin/main' into qa #49

Workflow file for this run

name: CD
on:
push: #ํ•ด๋‹น ๋ธŒ๋žœ์น˜์— push(merge) ํ–ˆ์„ ๋•Œ
branches:
- qa
permissions: write-all #ํ…Œ์ŠคํŠธ ๊ฒฐ๊ณผ ์ž‘์„ฑ์„ ์œ„ํ•ด ์“ฐ๊ธฐ๊ถŒํ•œ ์ถ”๊ฐ€
jobs:
build:
runs-on: ubuntu-latest
steps:
# 1) ์›Œํฌํ”Œ๋กœ์šฐ ์‹คํ–‰ ์ „ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ฒดํฌ์•„์›ƒ ํ•„์š”
- uses: actions/checkout@v3
# 2) JDK 17 ๋ฒ„์ „ ์„ค์น˜
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
# 3) Gradle Caching
- name: Gradle Cashing
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# 4) Gradle ๊ถŒํ•œ ๋ถ€์—ฌ
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# 5) Set for application-secret.yml
- name: Make application-secret.yml
run: |
cd ./src/main/resources
touch ./application-secret.yml
echo "${{ secrets.PROPERTIES_SECRET }}" > ./application-secret.yml
shell: bash
# 6) ๋กœ๊ทธ xml ํŒŒ์ผ ์„ค์ •
- name: Make logback-spring.xml
run: |
cd ./src/main/resources
touch ./logback-spring.xml
echo "${{ secrets.LOGBACK_SPRING }}" > ./logback-spring.xml
shell: bash
# 7) jar ํŒŒ์ผ ์ƒ์„ฑ
- name: Build With Gradle
run: ./gradlew bootJar
# 8) Docker ๋นŒ๋“œ & ํ‘ธ์‰ฌ
- name: docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY}} .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY}}
# 9) Deploy (DEV-Server)
- name: Deploy (DEV)
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
script: |
docker stop server
docker rm server
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY}}:latest
sudo docker-compose up -d
docker rmi -f $(docker images -f "dangling=true" -q)