-
Notifications
You must be signed in to change notification settings - Fork 11
58 lines (53 loc) · 1.9 KB
/
pr-approval-label.yaml
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
name: Manage Approved Label
on:
pull_request_review:
types: [submitted]
jobs:
approval-label:
runs-on: ubuntu-latest
name: Approval Label
steps:
- name: Sudo GitHub Token
id: sudo_github_token
uses: tibdex/github-app-token@v1.8.2
with:
app_id: ${{vars.SUDO_GHA_APP_ID}}
installation_id: ${{vars.SUDO_GHA_APP_INSTALLATION_ID}}
private_key: ${{secrets.SUDO_GHA_APP_PRIVATE_KEY}}
- name: Get pr info
uses: octokit/graphql-action@v2.x
id: get_pr_info
with:
variables: |
owner: "Scalr"
repo: ${{github.event.repository.name}}
pr: ${{github.event.pull_request.number}}
query: |
query ($owner: String!, $repo: String!, $pr: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $pr) {
reviewDecision
timelineItems(last: 250) {
edges {
node {
__typename
}
}
}
}
}
}
env:
GITHUB_TOKEN: ${{steps.sudo_github_token.outputs.token}}
- name: Set label
if: github.event.review.state == 'approved' && fromJson(steps.get_pr_info.outputs.data).repository.pullRequest.reviewDecision == 'APPROVED'
uses: actions-ecosystem/action-add-labels@v1
with:
labels: approved
github_token: ${{steps.sudo_github_token.outputs.token}}
- name: Remove label
if: github.event.review.state != 'approved' || fromJson(steps.get_pr_info.outputs.data).repository.pullRequest.reviewDecision != 'APPROVED'
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: approved
github_token: ${{steps.sudo_github_token.outputs.token}}