Skip to content

Commit b830082

Browse files
Abbondanzometa-codesync[bot]
authored andcommitted
Use current PR state in analyze workflow (#58411)
Summary: The Analyze Pull Request workflow validates `context.payload.pull_request`, which is the event snapshot saved when a workflow run was created. Rerunning an old run after the PR description or base branch changes therefore validates stale state and can replace a passing check with an incorrect failure. Fetch the current pull request through `github.rest.pulls.get` before validating its body and base branch so new runs and reruns behave consistently. ## Changelog: [INTERNAL] Pull Request resolved: #58411 Test Plan: - `git diff --check` - Parsed `.github/workflows/analyze-pr.yml` with Ruby YAML. - Executed both embedded `github-script` blocks with a mocked valid live PR and stale invalid event payload; both used the live state and passed. - Executed both blocks with an invalid live PR and valid stale event payload; both used the live state and failed. - Full repository formatting could not run locally because Yarn package downloads repeatedly failed through the environment proxy with HTTP 503. Reviewed By: christophpurrer Differential Revision: D119215496 Pulled By: Abbondanzo fbshipit-source-id: 08dfb4272b2f89d221d02665c39df49383a747e0
1 parent 12e979c commit b830082

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

.github/workflows/analyze-pr.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ jobs:
2525
with:
2626
script: |
2727
const validatePRBody = require('./.github/workflow-scripts/validatePRBody.js');
28-
const {message, status} = validatePRBody(context.payload.pull_request.body);
28+
const {data: pullRequest} = await github.rest.pulls.get({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
pull_number: context.issue.number,
32+
});
33+
const {message, status} = validatePRBody(pullRequest.body);
2934
core.setOutput('message', message);
3035
core.setOutput('status', status);
3136
- name: Check branch target
@@ -34,8 +39,14 @@ jobs:
3439
with:
3540
script: |
3641
const checkBranchTarget = require('./.github/workflow-scripts/checkBranchTarget.js');
37-
const baseRef = context.payload.pull_request.base.ref;
38-
const {message, status, shouldAddPickLabel} = checkBranchTarget(baseRef);
42+
const {data: pullRequest} = await github.rest.pulls.get({
43+
owner: context.repo.owner,
44+
repo: context.repo.repo,
45+
pull_number: context.issue.number,
46+
});
47+
const {message, status, shouldAddPickLabel} = checkBranchTarget(
48+
pullRequest.base.ref,
49+
);
3950
4051
if (shouldAddPickLabel) {
4152
await github.rest.issues.addLabels({

0 commit comments

Comments
 (0)