[llvm] [workflows] issue-write: Avoid race condition when PR branch is deleted (PR #87118)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 29 15:15:08 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-github-workflow
Author: Tom Stellard (tstellar)
<details>
<summary>Changes</summary>
Fixes #<!-- -->87102 .
---
Full diff: https://github.com/llvm/llvm-project/pull/87118.diff
1 Files Affected:
- (modified) .github/workflows/issue-write.yml (+9)
``````````diff
diff --git a/.github/workflows/issue-write.yml b/.github/workflows/issue-write.yml
index 02a5f7c213e898..cb5a96caf8e91e 100644
--- a/.github/workflows/issue-write.yml
+++ b/.github/workflows/issue-write.yml
@@ -77,6 +77,15 @@ jobs:
}
const gql_result = await github.graphql(gql_query, gql_variables);
console.log(gql_result);
+ // If the branch for the PR was deleted before this job has a chance
+ // to run, then the ref will be null. This can happen if someone:
+ // 1. Rebase the PR, which triggers some workflow.
+ // 2. Immediately merges the PR and deletes the branch.
+ // 3. The workflow finishes and triggers this job.
+ if (!gql_result.repository.ref) {
+ console.log("Ref has been deleted");
+ return;
+ }
console.log(gql_result.repository.ref.associatedPullRequests.nodes);
var pr_number = 0;
``````````
</details>
https://github.com/llvm/llvm-project/pull/87118
More information about the llvm-commits
mailing list