[FEAT] CI 설정 (#227) #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
# github repository actions 페이지에 나타날 이름 | |
name: Backend CI | |
# event trigger | |
# main 브랜치에 push, PR이 되었을 때 workflow 실행 | |
on: | |
push: | |
branches: [ "weekly","develop","main" ] | |
paths : '**' | |
pull_request: | |
branches: [ "weekly","develop","main" ] | |
paths : '**' | |
permissions: write-all | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: github actions에서 사용할 JDK를 설정합니다. | |
uses: actions/checkout@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: gradlew 실행 권한을 부여합니다. | |
run: chmod +x gradlew | |
shell : bash | |
- name: DB를 실행합니다. | |
run: | | |
docker-compose -f resources/local-develop-environment/docker-compose.yml up -d | |
sleep 20 | |
- 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: gradle를 build합니다. | |
run: ./gradlew build | |
- name: 테스트 결과를 PR에 코멘트로 등록합니다. | |
uses: EnricoMi/publish-unit-test-result-action@v1 | |
if: always() | |
with: | |
files: '**/build/test-results/test/TEST-*.xml' | |
- name: 테스트 실패 시, 실패한 코드 라인에 Check 코멘트를 등록합니다. | |
uses: mikepenz/action-junit-report@v3 | |
if: always() | |
with: | |
report_paths: '**/build/test-results/test/TEST-*.xml' | |
token: ${{ github.token }} | |
- name: build 실패 시 Slack으로 알립니다. | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
author_name: 백엔드 빌드 실패 알림 | |
fields: repo, message, commit, author, action, eventName, ref, workflow, job, took | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
if: failure() |