Kerdy Backend Dev Server CI/CD #4
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
name: Kerdy Backend Dev Server CI/CD | ||
on: | ||
workflow_dispatch: | ||
defaults: | ||
run: | ||
working-directory: backend/emm-sale | ||
permissions: | ||
contents: read | ||
jobs: | ||
build-and-upload: | ||
runs-on: ubuntu-22.04 | ||
services: | ||
mysql: | ||
image: mysql:8.0.28 | ||
env: | ||
MYSQL_USER: user | ||
MYSQL_PASSWORD: password | ||
MYSQL_ROOT_PASSWORD: 1234 | ||
MYSQL_DATABASE: kerdy | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
steps: | ||
- name: 백엔드 메인으로 checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: backend-main | ||
- name: JDK 11로 설정 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 11 | ||
distribution: 'temurin' | ||
- name: Gradle에 실행 권한 부여 | ||
run: chmod +x gradlew | ||
- name: Gradle 캐싱 | ||
id: cache-gradle | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: keystore 생성 | ||
id: generate-keystore | ||
run: | | ||
echo "$KEY_STORE" > keystore.b64 | ||
base64 -d -i keystore.b64 > keystore.p12 | ||
- name: keystore 이동 | ||
id: cp-keystore | ||
run: | | ||
cp keystore.p12 src/main/resources/ssl | ||
- name: gradle 빌드 | ||
run: ./gradlew build | ||
- name: 디버깅용 경로 출력 | ||
id: cp-keystore | ||
Check failure on line 67 in .github/workflows/backend-dev-deploy.yml GitHub Actions / Kerdy Backend Dev Server CI/CDInvalid workflow file
|
||
run: | | ||
pwd | ||
- name: jar artifact에 업로드 | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: BackendApplicationJar | ||
path: ./build/libs/*.jar | ||
deploy: | ||
runs-on: self-hosted | ||
steps: | ||
- name: 구버전 jar 삭제 | ||
working-directory: ./backend/build/ | ||
run: rm -f kerdy-*.jar | ||
- name: artifact에서 jar파일 다운 받기 | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: BackendApplicationJar | ||
path: backend/build/ | ||
- name: 배포하기 | ||
working-directory: ./backend/build/ | ||
run: | | ||
./deploy.sh | ||
- name: 슬랙 메시지 보내기 | ||
uses: 8398a7/action-slack@v3 | ||
with: | ||
mention: 'here' | ||
if_mention: failure | ||
status: ${{ job.status }} | ||
fields: workflow,job,commit,message,ref,author,took | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
if: always() |