diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 05650f00d51..444c76995e1 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -91,4 +91,4 @@ jobs: curl https://github.com/mattermost/mmctl/releases/download/v7.8.5/linux_amd64.tar -Lo mmctl.tar tar -xvf mmctl.tar ./mmctl auth login 'https://chat.charmhub.io' --name Charmhub --access-token $MM_TOKEN - ./mmctl post create Charmhub:juju-watercooler --message "$MESSAGE" + ./mmctl post create Charmhub:juju-bot --message "$MESSAGE" diff --git a/scripts/try-merge/main.go b/scripts/try-merge/main.go index 3cd7dfc47ec..f80630ff800 100644 --- a/scripts/try-merge/main.go +++ b/scripts/try-merge/main.go @@ -168,7 +168,8 @@ type commitInfo struct { } type prInfo struct { - Number int `json:"number"` + Number int `json:"number"` + State string `json:"state"` } // Check if there is already an open merge containing this commit. If so, @@ -178,9 +179,9 @@ func commitHasOpenPR(commit commitInfo) (prNumber int, ok bool) { command: "gh", args: []string{"pr", "list", "--search", commit.SHA, - "--state", "open", + "--state", "all", "--base", targetBranch, - "--json", "number", + "--json", "number,state", }, }) handleExecuteError(ghRes) @@ -188,8 +189,12 @@ func commitHasOpenPR(commit commitInfo) (prNumber int, ok bool) { prList := []prInfo{} check(json.Unmarshal(ghRes.stdout, &prList)) - if len(prList) > 0 { - return prList[0].Number, true + for _, pr := range prList { + // Check for merged PRs, just in case the merge PR landed while we've been + // checking for conflicts. + if pr.State == "OPEN" || pr.State == "MERGED" { + return pr.Number, true + } } return -1, false }