-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (63 loc) · 2.41 KB
/
ci-pull-request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: CI - Pull request
on:
issue_comment:
types: [ created ]
jobs:
build:
name: ready for launch (CI)
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '출격준비')}}
steps:
- name: Get PR branch
id: get_branch
run: |
PR_NUMBER=$(jq --raw-output .issue.number "$GITHUB_EVENT_PATH")
BRANCH_NAME=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" | \
jq -r .head.ref)
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: Repository 접근
uses: actions/checkout@v4
with:
ref: ${{ steps.get_branch.outputs.branch }}
- name: JDK 21 셋팅
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Gradle 의존성 캐싱
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: ktlint check
run: ./gradlew ktlintCheck
- name: 프로젝트 빌드
env:
SECRET_MANAGER_TOKEN: ${{ secrets.SECRET_MANAGER_TOKEN }}
SECRET_MANAGER_WORKSPACE: ${{ secrets.SECRET_MANAGER_WORKSPACE }}
CURRENT_GIT_SHA: ${{ github.sha }}
STATUS: PR
run: ./gradlew build
- name: Set build status output
id: set_status
run: echo "build_status=${{ job.status }}" >> $GITHUB_OUTPUT
- name: Comment on Pull Request
if: always()
uses: actions/github-script@v7
with:
script: |
const status = '${{ steps.set_status.outputs.build_status }}';
const message = status === 'success' ? '✅ 빌드 성공 ✅\n🚀 출격 준비 완료 👨🏻🚀' : '❌❌ 빌드 실패 ❌❌\n😵😵💫 코드 확인이 필요해요 😵😵💫';
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `${message}`
});