Skip to content

๐Ÿ› Swagger ์ˆ˜์ • (#31) #41

๐Ÿ› Swagger ์ˆ˜์ • (#31)

๐Ÿ› Swagger ์ˆ˜์ • (#31) #41

Workflow file for this run

name: cd with Gradle
on:
push:
branches:
- main # main ๋ธŒ๋žœ์น˜์— push๋  ๋•Œ
permissions: write-all # ํ…Œ์ŠคํŠธ ๊ฒฐ๊ณผ ์ž‘์„ฑ์„ ์œ„ํ•ด ์“ฐ๊ธฐ๊ถŒํ•œ ์ถ”๊ฐ€
jobs:
build:
if: github.event.pull_request.merged == true || github.event_name == 'push' # PR merge ๋˜๋Š” push์ผ ๋•Œ ์‹คํ–‰
runs-on: ubuntu-latest # ํ™˜๊ฒฝ
steps:
- name: Checkout repository
uses: actions/checkout@v3 # ์ฝ”๋“œ ์ฒดํฌ์•„์›ƒ = ๊ฐ€์ƒํ™˜๊ฒฝ ๋ณต์‚ฌ
- name: Set up JDK 21
uses: actions/setup-java@v3 #jdk ์ปดํŒŒ์ผ๋Ÿฌ
with:
java-version: '21'
distribution: 'temurin' # ์ž๋ฐ” ๊ฐœ๋ฐœ ํ‚คํŠธ ๋ฐฐํฌํŒ
- 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-
- name: Grant execute permission for Gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build -x test #๋นŒ๋“œ
- name: Ensure target directory exists
uses: appleboy/ssh-action@master # SSH๋ฅผ ํ†ตํ•ด ๋Œ€์ƒ ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ
with:
username: ubuntu
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_KEY }}
script: |
mkdir -p /home/ubuntu/gather_back_end
- name: List build directory
run: ls -la build/libs
- name: Transfer Build File using SCP
uses: appleboy/scp-action@master # .jar ํŒŒ์ผ ์›๊ฒฉ ์„œ๋ฒ„๋กœ ๋ณต์‚ฌ
with:
username: ubuntu
host: ${{ secrets.SSH_HOST }}
key: ${{ secrets.SSH_KEY }}
source: |
build/libs/gather_back_end-0.0.1-SNAPSHOT.jar
target: "/home/ubuntu/gather_back_end"
- name: Deploy using Docker Compose via SSH(Prod)
if: github.ref == 'refs/heads/main'
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ubuntu
key: ${{ secrets.SSH_KEY }}
script_stop: true
script: |
cd /home/ubuntu/gather_back_end || exit 1 # ๊ฒฝ๋กœ ๋ณ€๊ฒฝ ์‹คํŒจ ์‹œ ์ข…๋ฃŒ
sudo docker compose down
sudo docker compose up --build -d