RELEASE 2024-12-05 21:39:30 #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | |
name: API-Server CD | |
on: | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
ci-workflow: | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ./ | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: make application.yml 파일 생성 | |
run: | | |
## create application.yml | |
cd ./module-api/src/main/resources | |
# application.yml 파일 생성 | |
touch ./application.yml | |
# GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기 | |
echo "${{ secrets.FOURCUTDIARY_APPLICATION }}" >> ./application.yml | |
shell: bash | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: docker build 가능하도록 환경 설정 | |
uses: docker/[email protected] | |
- name: docker hub에로그인 | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_LOGIN_USER }} | |
password: ${{ secrets.DOCKERHUB_LOGIN_ACCESS_TOKEN }} | |
- name: docker image 빌드 및 푸시 | |
run: | | |
docker build --platform linux/amd64 -t lsh328328/fourcutdiary . | |
docker push lsh328328/fourcutdiary | |
working-directory: ${{ env.working-directory }} | |
cd-workflow: | |
needs: ci-workflow | |
runs-on: ubuntu-latest | |
steps: | |
- name: 도커 컨테이너 실행 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.RELEASE_SERVER_IP }} | |
username: ${{ secrets.RELEASE_SERVER_USER }} | |
key: ${{ secrets.RELEASE_SERVER_KEY }} | |
script: | | |
cd ~ | |
./deploy.sh |