Skip to content

Commit

Permalink
Use earlier instead of current
Browse files Browse the repository at this point in the history
  • Loading branch information
iamnafets committed Oct 31, 2023
1 parent 8df2a83 commit 1b94eaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9597,8 +9597,10 @@ function run() {
.sort((r1, r2) => new Date(r2.created_at).getTime() - new Date(r1.created_at).getTime());
let triggeringSha = process.env.GITHUB_SHA;
let sha = undefined;
let lastSha;
if (runs.length > 0) {
for (const run of runs) {
lastSha = run.head_sha;
core.debug(`This SHA: ${triggeringSha}`);
core.debug(`Run SHA: ${run.head_sha}`);
core.debug(`Run Branch: ${run.head_branch}`);
Expand Down Expand Up @@ -9636,8 +9638,8 @@ function run() {
core.info(`No previous runs found for branch ${inputs.branch}.`);
}
if (!sha) {
core.warning("Unable to determine SHA of last successful commit. Using SHA for current commit.");
sha = triggeringSha;
core.warning(`Unable to determine SHA of last successful commit (possibly outside the window of ${runs.length} runs). Using earliest SHA available.`);
sha = lastSha;
}
core.setOutput('sha', sha);
}
Expand Down
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ async function run(): Promise<void> {

let triggeringSha = process.env.GITHUB_SHA as string;
let sha: string | undefined = undefined;
let lastSha: string | undefined;

if (runs.length > 0) {
for (const run of runs) {
lastSha = run.head_sha;
core.debug(`This SHA: ${triggeringSha}`);
core.debug(`Run SHA: ${run.head_sha}`);
core.debug(`Run Branch: ${run.head_branch}`);
Expand Down Expand Up @@ -109,8 +111,8 @@ async function run(): Promise<void> {
}

if (!sha) {
core.warning("Unable to determine SHA of last successful commit. Using SHA for current commit.");
sha = triggeringSha;
core.warning(`Unable to determine SHA of last successful commit (possibly outside the window of ${runs.length} runs). Using earliest SHA available.`);
sha = lastSha;
}

core.setOutput('sha', sha);
Expand Down

0 comments on commit 1b94eaa

Please sign in to comment.