-
Notifications
You must be signed in to change notification settings - Fork 22
58 lines (45 loc) · 1.85 KB
/
merged-pr-labeler.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: Merged pull request labeler
# What the execution context is:
# The merging (not just closing) of a pull request.
# What it does:
# Assigns the 'valuable contribution' label.
# Why we need it:
# To mark a valuable pull request contribution, and thus to cause the
# SAP Community profile URL requester to be triggered.
# What's important to know:
# The label to assign is defined at the start of the job, in the LABEL
# environment variable. The label is not assigned if the actor is an administrator.
on:
pull_request_target:
types: [closed]
jobs:
assign-label-on-merge:
if: contains(github.repositoryUrl, 'github.com') && github.event.pull_request.merged
env:
LABEL: "contribution"
runs-on: ubuntu-20.04
steps:
- id: token_gen
name: Generate app installation token
uses: machine-learning-apps/[email protected]
with:
APP_PEM: ${{ secrets.SAP_CODOC_APP_PEM_BASE64 }}
APP_ID: ${{ secrets.SAP_CODOC_APP_ID }}
- id: checkout
name: Check out the repo
uses: actions/checkout@v3
with:
token: ${{ steps.token_gen.outputs.app_token }}
- id: auth_gh
name: Authenticate gh to repo
run: echo -n ${{ steps.token_gen.outputs.app_token }} | gh auth login --with-token
- id: determine_permission
name: Look up repository permission level for PR author
run: |
pr_author="$(gh api --jq .user.login "${{ github.event.pull_request._links.self.href }}")"
permission="$(gh api --jq .permission "/repos/$GITHUB_REPOSITORY/collaborators/$pr_author/permission")"
echo "pr_author=$pr_author"
echo "repo_permission=$permission" | tee --append "$GITHUB_ENV"
- id: assign_label
if: env.repo_permission != 'admin'
run: gh pr edit ${{ github.event.number }} --add-label "$LABEL"