Skip to content

[BUILD SUCCESS] 엑세스 토큰 재발급 기능 #51

[BUILD SUCCESS] 엑세스 토큰 재발급 기능

[BUILD SUCCESS] 엑세스 토큰 재발급 기능 #51

name: Test And Build
on:
pull_request:
types: [ opened, reopened, synchronize ]
branches: [ 'main' ]
jobs:
build_and_test:
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
packages: write
pull-requests: write
issues: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- 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
id: build_and_test
run:
./gradlew clean build --stacktrace
- name: If build success
if: success()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pull_number = ${{ github.event.pull_request.number }}
const updated_title = `[BUILD SUCCESS] ${{ github.event.pull_request.title }}`
await github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull_number,
body: '빌드에 성공했습니다.',
event: 'COMMENT'
})
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull_number,
title: updated_title,
state: 'open'
})
- name: If build fail
if: failure()
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: 'COMMENT'
})
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull_number,
title: updated_title,
state: 'open'
})
- name: Send Build Fail Message to Discord
if: 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: 테스트 실패 시, 실패한 코드 라인에 Check 코멘트를 등록합니다
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
token: ${{ secrets.GITHUB_TOKEN }}