-
Notifications
You must be signed in to change notification settings - Fork 5
83 lines (74 loc) · 2.36 KB
/
test_pr.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
74
75
76
77
78
79
80
81
82
83
name: Test Server Pull-request # Workflow 이름
on:
pull_request:
branches: [ "test" ]
jobs:
build:
runs-on: ubuntu-latest
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379
steps:
- name: Checkout source code. # Repo checkout
uses: actions/checkout@v3
- name: Set application.properties from secrets
run: |
echo "${{ secrets.TEST_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: ${{ 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: ${{ github.token }}
script: |
github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
event: 'APPROVE'
});