Feature 27 엔티티 개선작업 #2
Workflow file for this run
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: Test And Build And Deploy | |
on: | |
pull_request: | |
types: [ opened, reopened, edited, synchronize ] | |
branches: [ 'main' ] | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
pull-requests: write | |
issues: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | |
settings-path: ${{ github.workspace }} # location for the settings.xml file | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Import secret files | |
run: | | |
echo -e "${{ secrets.APPLICATION_COMMON}}" >> ./src/main/resources/application-common.yml | |
echo -e "${{ secrets.APPLICATION_PRODUCT}}" >> ./src/main/resources/application-product.yml | |
echo -e "${{ secrets.APPLICATION_LOCAL}}" >> ./src/main/resources/application-local.yml | |
echo -e "${{ secrets.APPLICATION_INFO_LOGGING}}" >> ./src/main/resources/application-info-logging.yml | |
echo -e "${{ secrets.APPLICATION_DEBUG_LOGGING}}" >> ./src/main/resources/application-debug-logging.yml | |
- name: Build with Gradle | |
continue-on-error: true | |
id: build_and_test | |
run: | |
./gradlew clean build --stacktrace | |
- name: If build fail | |
continue-on-error: true | |
# 이전 step이 실패한 경우에만 이 step을 실행시키는 syntax | |
if: ${{ steps.build_and_test.outcome == 'failure'}} | |
id: close_pr | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const pull_number = ${{ github.event.pull_request.number }} | |
const updated_title = `[BUILD FAIL] ${{ github.event.pull_request.title }}` | |
await github.rest.pulls.createReview({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: pull_number, | |
body: '빌드에 실패했습니다.', | |
event: 'REQUEST_CHANGES' | |
}) | |
await github.rest.pulls.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: pull_number, | |
title: updated_title, | |
state: 'closed' | |
}) | |
- name: Send Build Fail Message to Discord | |
continue-on-error: true | |
if: ${{ steps.build_and_test.outcome == 'failure'}} | |
run: | | |
curl --location ${{secrets.DISCORD_WEBHOOK_URL}} \ | |
--header 'Content-Type: application/json' \ | |
--data '{ | |
"avatar_url": "https://cdn-icons-png.flaticon.com/512/25/25231.png", | |
"embeds": [ | |
{ | |
"title": "${{ github.event.pull_request.title }}", | |
"type": "rich", | |
"description": "빌드가 실패했습니다.", | |
"url": "https://github.com/Cafegory/Cafegory_Backend_REST_API/pull/${{github.event.number}}" | |
} | |
]}' | |
- name: Send Build Success Message to Discord | |
continue-on-error: true | |
if: ${{ steps.build_and_test.outcome == 'success'}} | |
run: | | |
curl --location ${{secrets.DISCORD_WEBHOOK_URL}} \ | |
--header 'Content-Type: application/json' \ | |
--data '{ | |
"avatar_url": "https://cdn-icons-png.flaticon.com/512/25/25231.png", | |
"embeds": [ | |
{ | |
"title": "${{ github.event.pull_request.title }}", | |
"type": "rich", | |
"description": "빌드가 성공했습니다! 아싸!", | |
"url": "https://github.com/Cafegory/Cafegory_Backend_REST_API/pull/${{github.event.number}}" | |
} | |
]}' |