Skip to content

Testing Issue Label Assignment / Removal #1

Testing Issue Label Assignment / Removal

Testing Issue Label Assignment / Removal #1

##############################################################################
##############################################################################
#
# NOTE!
#
# Please read the README.md file in this directory that defines what should
# be placed in this file
#
##############################################################################
##############################################################################
name: Issue Assignment Workflow
on:
issues:
types: ['assigned']
permissions:
contents: read
issues: write
jobs:
Remove-Unapproved-Label:
name: Remove Unapproved Label when issue is assigned
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const apiParams = {
owner,
repo,
issue_number
};
// Get current labels on the issue
const { data: labelList } = await github.rest.issues.listLabelsOnIssue(apiParams);
const unapprovedLabel = labelList.find(l =>
l.name.toLowerCase().includes('unapprov') // matches 'unapproved' too
);
// Remove unapproved label if it exists
if (unapprovedLabel) {
try {
await github.rest.issues.removeLabel({
owner,
repo,
issue_number,
name: unapprovedLabel.name,
});
} catch (err) {
if (err.status !== 404) throw err;
}
}