File tree Expand file tree Collapse file tree
.github/actions/determine-modified-challenges Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,12 +20,12 @@ runs:
2020 with :
2121 script : |
2222 let ref = "";
23+ const { owner, repo } = context.repo;
24+ const branch = context.ref.replace("refs/heads/", "");
2325 if (context.eventName === "pull_request") {
2426 ref = context.payload.pull_request.base.sha;
2527 } else if (context.eventName === "push") {
2628 const workflowFile = process.env.GITHUB_WORKFLOW_REF.split("@")[0].split("/").pop();
27- const branch = context.ref.replace("refs/heads/", "");
28- const { owner, repo } = context.repo;
2929 const runs = await github.rest.actions.listWorkflowRuns({
3030 owner,
3131 repo,
3737 const [latest] = runs.data.workflow_runs;
3838 ref = latest ? latest.head_sha : "";
3939 }
40+ if (ref) {
41+ try {
42+ const comparison = await github.rest.repos.compareCommitsWithBasehead({
43+ owner,
44+ repo,
45+ basehead: `${ref}...${context.sha}`,
46+ });
47+ if (!["ahead", "identical"].includes(comparison.data.status)) {
48+ core.warning(`${ref} is not an ancestor of the current commit; branch history may have changed`);
49+ ref = "";
50+ }
51+ } catch {
52+ core.warning(`${ref} could not be compared with the current commit`);
53+ ref = "";
54+ }
55+ }
4056 core.setOutput("ref", ref);
4157
4258 - uses : actions/checkout@v6
You can’t perform that action at this time.
0 commit comments