mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 22:50:26 +01:00
Allows labeler action to add/remove labels from the PR title/body on sync (#92553)
## About The Pull Request Followup to https://github.com/tgstation/tgstation/pull/92504 Removes the conditional that was stopping the labeler from checking the PR body for labels on sync. <details><summary>No more of this weirdness</summary> <img width="877" height="488" alt="firefox_zppJmK5qz2" src="https://github.com/user-attachments/assets/74a556b5-a3e3-40e7-93dd-e18c62ed9649" /> </details> Any time someone updates a PR and it syncs, you can potentially lose some of the PR labels from the body (the changelog specifically) if they are not configured as `add_only` in the autoLabelConfig.js I had kept it in previously since it was how it was before, but thinking on it I do not think this is even necessary anymore now that the php webhook method is replaced with the action. Let's remove it! ## Why It's Good For The Game QoL for maintainers and contributors ## Changelog Nothing player-facing
This commit is contained in:
@@ -173,7 +173,7 @@ async function check_diff_files_for_labels(github, context) {
|
||||
* Main function to get the updated label set
|
||||
*/
|
||||
export async function get_updated_label_set({ github, context }) {
|
||||
const { action, pull_request } = context.payload;
|
||||
const { pull_request } = context.payload;
|
||||
const {
|
||||
body = "",
|
||||
diff_url,
|
||||
@@ -192,14 +192,38 @@ export async function get_updated_label_set({ github, context }) {
|
||||
labels_to_remove.forEach((label) => updated_labels.delete(label));
|
||||
}
|
||||
|
||||
// Check body/title only when PR is opened, not on sync
|
||||
if (action === "opened") {
|
||||
if (title)
|
||||
check_title_for_labels(title).forEach((label) =>
|
||||
updated_labels.add(label)
|
||||
);
|
||||
if (body)
|
||||
check_body_for_labels(body).forEach((label) => updated_labels.add(label));
|
||||
// Always check body/title (otherwise we can lose the changelog labels)
|
||||
if (title)
|
||||
check_title_for_labels(title).forEach((label) =>
|
||||
updated_labels.add(label)
|
||||
);
|
||||
if (body)
|
||||
check_body_for_labels(body).forEach((label) => updated_labels.add(label));
|
||||
|
||||
// Keep track of labels that were manually added by maintainers in the events.
|
||||
// And make sure they -stay- added.
|
||||
try {
|
||||
await github.paginate(
|
||||
github.rest.issues.listEventsForTimeline,
|
||||
{
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.pull_request.number,
|
||||
per_page: 100,
|
||||
},
|
||||
(response) => {
|
||||
for (const eventData of response.data) {
|
||||
if (
|
||||
eventData.event === "labeled" &&
|
||||
eventData.actor?.login !== "github-actions"
|
||||
) {
|
||||
updated_labels.add(eventData.label.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error fetching paginated events:", error);
|
||||
}
|
||||
|
||||
// Always remove Test Merge Candidate
|
||||
|
||||
Reference in New Issue
Block a user