Skip to content

Fix Release Labels (Maintainers Only) #8

Fix Release Labels (Maintainers Only)

Fix Release Labels (Maintainers Only) #8

Workflow file for this run

name: Fix Release Labels (Maintainers Only)
on:
# Runs manually by maintainer
workflow_dispatch:
inputs:
update:
description: 'Do you want to update the release labels?'
required: false
default: false
type: boolean
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@v5
with:
script: |
const update = core.getInput('update') === 'true';
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);
// Log just first 15 issues
const issuesToLog = issuesWithoutReleasedLabel.slice(0, 15);
console.log('Here is some of them: ', issuesToLog.map(issue => '#' + issue.number).join(', '));
if (update) {
for (const issue of issues) {
console.log(`Adding 'released' label to issue #${issue}`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue,
labels: ['released']
});
console.log(`Removing 'released on @beta' label from issue #${issue}`);
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue,
name: 'released on @beta'
});
}
} else {
console.log('Was run in dry-run mode, no changes were made');
}