forked from AmadeusITGroup/otter
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (47 loc) · 1.61 KB
/
pr-labels.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
name: Pull Request Label
on: pull_request
permissions:
contents: read
jobs:
setup-label:
runs-on: ubuntu-latest
env:
SKIP_ON_LABELS: '["cascading"]'
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
permissions:
pull-requests: write
issues: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup
uses: ./tools/github-actions/setup
- name: Determine labels
run: |
LABELS="$(yarn pr-labels --target="${{ github.base_ref || github.ref_name }}")"
echo "LABELS=$LABELS" >> $GITHUB_ENV
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: env.LABELS != '[]'
continue-on-error: true
with:
script: |
const [owner, repo] = '${{ github.repository }}'.split('/');
const pLabels = github.rest.issues.listLabelsOnIssue({
owner,
repo,
issue_number: context.issue.number
});
return pLabels.then((labels) => {
const skipLabelUpdate = labels.data.some(({ name }) => ${{ env.SKIP_ON_LABELS }}.includes(name));
if (skipLabelUpdate) {
github.log.info('Skip label setting for this Pull Request.');
return ;
}
return github.rest.issues.addLabels({
owner,
repo,
issue_number: context.issue.number,
labels: ${{ env.LABELS }}
});
});