-
Notifications
You must be signed in to change notification settings - Fork 340
75 lines (64 loc) · 2.36 KB
/
label-issues.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
name: Label Client Issues
on:
issues:
types: [opened, edited]
workflow_dispatch:
permissions:
issues: write
jobs:
label:
runs-on: ubuntu-latest
steps:
- name: Fetch issue details
id: fetch_issue
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
// Fetch the issue details using the GitHub API
const { data: issue } = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
return issue.body;
- name: Check issue body for client type
id: check_label
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const labelsToAdd = [];
const publicClientOptions = ["PublicClient"];
const confidentialClientOptions = ["ConfidentialClient"];
const managedIdentityClientOptions = ["ManagedIdentityClient"];
const issueBody = ${{ steps.fetch_issue.outputs.result }};
if (!issueBody) {
throw new Error('Issue body is undefined');
}
if (publicClientOptions.some(option => issueBody.includes(option))) {
labelsToAdd.push('public-client');
}
if (confidentialClientOptions.some(option => issueBody.includes(option))) {
labelsToAdd.push('confidential-client');
}
if (managedIdentityClientOptions.some(option => issueBody.includes(option))) {
labelsToAdd.push('scenario:ManagedIdentity');
}
return labelsToAdd;
- name: Add labels to the issue
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const labelsJson = '${{ steps.check_label.outputs.result }}';
console.log(labelsJson);
const labels = JSON.parse(labelsJson);
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labels
});
}