-
Notifications
You must be signed in to change notification settings - Fork 8
63 lines (56 loc) · 2.19 KB
/
fix-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
54
55
56
57
58
59
60
61
62
63
name: Fix Release Labels (Maintainers Only)
on:
# Runs manually by maintainer
workflow_dispatch:
permissions:
contents: write
issues: write
pull-requests: write
statuses: write
jobs:
find-n-fix-release-label:
name: Find and Fix Release Labels
runs-on: ubuntu-latest
steps:
# Check permissions
- uses: tspascoal/get-user-teams-membership@v3
id: permissions
with:
username: ${{ github.actor }}
team: 'ESL Core Maintainers'
GITHUB_TOKEN: ${{ secrets.PERMISSION_CHECK_TOKEN }}
- if: ${{ steps.permissions.outputs.isTeamMember == 'true' }}
name: Access Check Passed
run: echo ${{ github.actor }} is in 'ESL Core Maintainers' group
- if: ${{ steps.permissions.outputs.isTeamMember == 'false' }}
name: Access Denied
run: exit 1
- name: Find and fix 'released on @beta' issues without 'released' label
id: find-issues
uses: actions/github-script@v7
with:
script: |
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
labels: 'released on @beta',
state: 'all'
});
const issuesWithoutReleasedLabel = issues.filter(issue => !issue.labels.some(label => label.name === 'released'));
console.log('Found %d issues without "released" label', issuesWithoutReleasedLabel.length);
for (const issue of issuesWithoutReleasedLabel) {
console.log(`Adding 'released' label to issue #${issue.number}`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: ['released']
});
console.log(`Removing 'released on @beta' label from issue #${issue.number}`);
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
name: 'released on @beta'
});
}