Make script more resilient to racing events (#31013)

This commit is contained in:
Felix Becker 2022-02-10 14:01:01 -08:00 committed by GitHub
parent d2b66247fa
commit 04d5326c1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -2,7 +2,8 @@ name: "[OPTIONAL/DOESN'T BLOCK MERGING] Code Insights GitHub project automation"
on:
issues:
types: [opened, closed, reopened, milestoned, labeled]
# Note: labeled/milestoned is also triggered when opening a new issue with labels/milestone
types: [closed, reopened, milestoned, labeled]
pull_request:
types: [opened, edited, synchronize, ready_for_review, converted_to_draft]

View File

@ -32,7 +32,7 @@ switch ($github.event_name) {
Write-Information "Issue was $($github.event.action)"
if ($github.event.action -in 'opened', 'labeled', 'milestoned') {
if ($github.event.action -in 'labeled', 'milestoned') {
# If issue was labeled, make sure to only consider the team label being added (don't send a Slack message for every label added).
if ($github.event.action -eq 'labeled' -and $github.event.label.name -ne $TeamLabel) {
Write-Information "Labeled with non-team label ($($github.event.label.name)), exiting."
@ -44,12 +44,12 @@ switch ($github.event_name) {
return
}
# If team label was added or issue was just opened, add to project board
# If team label was added, add to project board
# If added to an iteration, update status and set "proposed by" to the event actor
# Idempotent, will return the item if already exists in the board (this is fine because we checked for the team label)
$item = [pscustomobject]$github.event.issue | Add-GitHubBetaProjectItem -ProjectNodeId $ProjectNodeId
if ($item.content.milestone) {
if ($github.event.issue.milestone) {
$proposer = $github.event.sender.login
Write-Information "Updating issue as 'Proposed for iteration' by @$proposer"