You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: enforce planning label rules for issues (#421)
related: #327
This new GitHub Actions workflow listens for the 'opened' and 'labeled' events on GitHub issues and ensures any issue opened (or labelled) with a `kind/plan-xxx` label meets the following criteria:
- only users listed in the `AUTHORIZED_USER` JSON array can label an issue with the `kind/plan-xxx` label
- at most one of the `kind/plan-xxx` labels can exist on a given issue
The set of supported/expected `kind/plan-xxx` labels are:
- `kind/plan-epic`
- `kind/plan-feature`
- `kind/plan-task`
If an issue (with a `kind/plan-xxx` label) is **opened** by a non-authorized user - the issue will be automatically closed when the GitHub action fires.
If an issue is labelled with the `kind/plan-xxx` label by an unauthorized user - the `kind/plan-xxx` label is removed.
In both cases, a GitHub comment is added to the issue explaining why the issue was updated by the bot.
Please note, when opening a GH issue - **BOTH** the `opened` and `labeled` events will fire (if the issue has a label on it). As such, the GitHub action in this PR was deliberately structured to account for multiple instances running in parallel on the same underlying GitHub issue.
Also, this work complements #361 - which defines GH issue templates that use the labels in a manner appropriate to satisfy the checks of this action.
Signed-off-by: Andy Stoneberg <[email protected]>
// Add a comment explaining why the label was removed
85
+
await github.rest.issues.createComment({
86
+
owner: context.repo.owner,
87
+
repo: context.repo.repo,
88
+
issue_number: issueNumber,
89
+
body: `@${actor} Planning labels require exactly one planning label to be present: ${planningLabels.join(', ')}. Please ensure only one planning label is applied.`
90
+
});
91
+
92
+
core.setFailed(`Planning labels require exactly one of: ${planningLabels.join(', ')}`);
93
+
}
94
+
95
+
console.log(`Issue has valid planning label: ${presentPlanningLabels[0]}`);
0 commit comments