Skip to content

Commit 649f960

Browse files
authored
[workflows] issue-write: Avoid race condition when PR branch is deleted (llvm#87118)
Fixes llvm#87102 .
1 parent 1e15371 commit 649f960

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

.github/workflows/issue-write.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ jobs:
7777
}
7878
const gql_result = await github.graphql(gql_query, gql_variables);
7979
console.log(gql_result);
80+
// If the branch for the PR was deleted before this job has a chance
81+
// to run, then the ref will be null. This can happen if someone:
82+
// 1. Rebase the PR, which triggers some workflow.
83+
// 2. Immediately merges the PR and deletes the branch.
84+
// 3. The workflow finishes and triggers this job.
85+
if (!gql_result.repository.ref) {
86+
console.log("Ref has been deleted");
87+
return;
88+
}
8089
console.log(gql_result.repository.ref.associatedPullRequests.nodes);
8190
8291
var pr_number = 0;

0 commit comments

Comments
 (0)