Skip to content

Commit 8a992c6

Browse files
authored
Merge pull request #4265 from github/henrymercer/notify-enqueuer-on-dequeue
Ping the user who enqueued a PR when it's removed from the merge queue
2 parents c9ae8b9 + 9ff762d commit 8a992c6

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

‎.github/workflows/pr-dequeued.yml‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,23 @@ jobs:
2121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2222
PR_NUMBER: ${{ github.event.pull_request.number }}
2323
REASON: ${{ github.event.reason }}
24-
USER: ${{ github.event.pull_request.user.login }}
2524
run: |
26-
echo "@$USER The pull request was removed from the merge queue (\`$REASON\`)." \
25+
# Mention whoever added the PR to the merge queue rather than the PR author, who may be a
26+
# bot such as Dependabot. The `dequeued` event payload doesn't identify the enqueuer, so
27+
# look them up in the most recent `AddedToMergeQueueEvent` on the PR's timeline.
28+
enqueuer=$(gh api graphql \
29+
-F number="$PR_NUMBER" \
30+
-f query='
31+
query($number: Int!) {
32+
repository(owner: "github", name: "codeql-action") {
33+
pullRequest(number: $number) {
34+
timelineItems(itemTypes: [ADDED_TO_MERGE_QUEUE_EVENT], last: 1) {
35+
nodes { ... on AddedToMergeQueueEvent { enqueuer { login } } }
36+
}
37+
}
38+
}
39+
}' \
40+
--jq '.data.repository.pullRequest.timelineItems.nodes[0].enqueuer.login')
41+
echo "@$enqueuer The pull request was removed from the merge queue (\`$REASON\`)." \
2742
"Please resolve any issues if required and enqueue the PR again." |
2843
gh pr comment --body-file - --repo github/codeql-action "$PR_NUMBER"

0 commit comments

Comments
 (0)