축제용 배포 #33
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: Main Server Pull-request | |
on: | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check branch | |
run: | | |
echo "Head branch is: ${{ github.head_ref }}" | |
echo "Base branch is: ${{ github.base_ref }}" | |
if [[ "${{ github.head_ref }}" != "test" ]]; then | |
echo "test 브랜치가 아님" | |
exit 1 | |
fi | |
- name: Checkout source code. # Repo checkout | |
uses: actions/checkout@v3 | |
- name: Set application.properties from secrets | |
run: | | |
echo "${{ secrets.MAIN_APPLICATION_PROPERTIES }}" > src/main/resources/application.properties | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
after: | |
runs-on: ubuntu-latest | |
needs: build | |
if: always() | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Comment on failure and close PR | |
if: needs.build.result == 'failure' | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '빌드 실패' | |
}); | |
github.rest.pulls.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.payload.pull_request.number, | |
state: 'closed' | |
}); | |
- name: Auto approve pull request | |
if: needs.build.result == 'success' | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.rest.pulls.createReview({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.payload.pull_request.number, | |
event: 'APPROVE' | |
}); |