diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index c2b33ef8adba..38f5071efebd 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -255,6 +255,13 @@ jobs: const stale_at = new Date(new Date().setDate(new Date().getDate() - 180)) + // After creation of a Pull Request, `merge_commit_sha` will be null initially: + // The very first merge commit will only be calculated after a little while. + // To avoid labeling the PR as conflicted before that, we wait a few minutes. + // This is intentionally less than the time that Eval takes, so that the label job + // running after Eval can indeed label the PR as conflicted if that is the case. + const merge_commit_sha_valid = new Date() - new Date(pull_request.created_at) > 3 * 60 * 1000 + // Manage most of the labels, without eval results const after = Object.assign( {}, @@ -271,7 +278,7 @@ jobs: // On the first pass of the day, we just fetch the pull request, which triggers // the creation. At this stage, the label is likely not updated, yet. // The second pass will then read the result from the first pass and set the label. - '2.status: merge conflict': !pull_request.merge_commit_sha, + '2.status: merge conflict': merge_commit_sha_valid && !pull_request.merge_commit_sha, '2.status: stale': !before['1.severity: security'] && latest_event_at < stale_at, '12.approvals: 1': approvals.size == 1, '12.approvals: 2': approvals.size == 2,