Repository navigation
fix(labels): add and remove deploy labels without replacing the pr's label set - #280
Conversation
…label set The label job replaced every label on the pull request with a snapshot taken from the webhook payload. When autoDeploy queued the deploy label right after a PR opened, labels applied in the seconds after open (bots like Dependabot add them in a separate call) were missing from that snapshot and got wiped. Use GitHub's add-labels and remove-label endpoints instead, so Lifecycle only touches the labels it owns. Removing a label that is already gone is treated as success. TTL cleanup gets the same treatment when it swaps the deploy label for the disabled label.
…ore removing deploy
vmelikyan
left a comment
There was a problem hiding this comment.
lgtm, the POST/DELETE split fixes the label wipe and the add-before-remove order in ttl is the right call.
one edge case, not blocking: in cleanupStaleEnvironment, if the disabled label is added and the deploy label removal fails, the next scan skips the PR (it already has the disabled label), so the deploy label stays and the ttl comment never posts. the env still tears down through the kill switch. could be a follow-up: either don't skip when both labels are present, or catch the remove failure and still post the comment.
nit: on close, label.ts only removes deploy labels that were in the webhook payload. removing all configured deploy labels would cover one added after the event, since 404 is already handled.
… live PR labels on close
|
Thanks! Fixed both in d227c13:
|
Description
autoDeploy: true, Lifecycle could strip every other label from a pull request when it added the deploy label. The label job sentPUT /issues/{n}/labelswith the label list from theopenedwebhook plus the deploy label, and that call replaces the whole set. Labels applied in the seconds after the PR opened were missing from that list and got removed. Bots such as Dependabot hit this every time, because they open the PR first and add labels in a separate call.POST /issues/{n}/labelsand removes deploy labels one at a time withDELETE /issues/{n}/labels/{name}, so Lifecycle only touches labels it owns. On close it reads the PR's current labels first, so a deploy label added after the webhook was sent is removed too.updatePullRequestLabels(the replace-all helper) is removed; nothing calls it anymore.Verifying Changes
eslintandjestpass;tscshows only errors that already exist onmain.autoDeploy: falseand manual add/remove of the deploy label still behave as before. A close racing a manual removal finishes cleanly. With two deploy labels configured, close removes both. TTL cleanup keeps unrelated labels. A full deploy still succeeds.