-
Notifications
You must be signed in to change notification settings - Fork 3k
40 lines (36 loc) · 1.23 KB
/
addLabelOnPr.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
name: Add Label on Pull Request
on:
workflow_call:
inputs:
labelName:
required: true
type: string
env:
GITHUB_APPS_ID: "${{ secrets.APPLICATION_ID }}"
GITHUB_APPS_KEY: "${{ secrets.APPLICATION_PRIVATE_KEY }}"
jobs:
addLabelOnPR:
if: ${{ !github.event.pull_request.head.repo.fork }}
runs-on: ubuntu-latest
steps:
- name: Generate a token
id: generate_token
uses: actions/create-github-app-token@46e4a501e119d39574a54e53a06c9a705efc55c9
with:
app-id: ${{ env.GITHUB_APPS_ID }}
private-key: ${{ env.GITHUB_APPS_KEY }}
- uses: actions/github-script@b7fb2001b410c9390cbe9e2c7d5cab7eefb7b29c
name: Add Label To Pull Request
env:
APPTOKEN: ${{ steps.generate_token.outputs.token }}
with:
github-token: ${{ env.APPTOKEN }}
script: |
$labelName = "${{ inputs.labelName }}"
console.log('PR Number : ' + context.issue.number + ', LabelName ' + $labelName)
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [$labelName]
})