Skip to content

Commit

Permalink
fix filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
ckotzbauer committed Aug 4, 2021
1 parent cb02d9a commit 9b90337
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6120,8 +6120,9 @@ function run() {
else {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Discovered workflowId for search: ${workflowId}`);
}
const response = yield octokit.actions.listWorkflowRuns({ owner, repo, workflow_id: workflowId, branch: inputs.branch, status: "success" });
const response = yield octokit.actions.listWorkflowRuns({ owner, repo, workflow_id: workflowId, per_page: 100 });
const runs = response.data.workflow_runs
.filter(x => (!inputs.branch || x.head_branch === inputs.branch) && x.conclusion === "success")
.sort((r1, r2) => new Date(r2.created_at).getTime() - new Date(r1.created_at).getTime());
let sha = process.env.GITHUB_SHA;
if (runs.length > 0) {
Expand All @@ -6130,7 +6131,7 @@ function run() {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Run SHA: ${run.head_sha}`);
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Run Branch: ${run.head_branch}`);
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Wanted branch: ${inputs.branch}`);
if (sha != run.head_sha && run.head_branch === inputs.branch) {
if (sha != run.head_sha && (!inputs.branch || run.head_branch === inputs.branch)) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Using extracted sha ${run.head_sha} from run ${run.html_url} instead of triggering sha ${sha}.`);
sha = run.head_sha;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ async function run(): Promise<void> {
core.info(`Discovered workflowId for search: ${workflowId}`);
}

const response = await octokit.actions.listWorkflowRuns({ owner, repo, workflow_id: workflowId, branch: inputs.branch, status: "success" });
const response = await octokit.actions.listWorkflowRuns({ owner, repo, workflow_id: workflowId, per_page: 100 });
const runs = response.data.workflow_runs
.filter(x => (!inputs.branch || x.head_branch === inputs.branch) && x.conclusion === "success")
.sort((r1, r2) => new Date(r2.created_at).getTime() - new Date(r1.created_at).getTime());

let sha = process.env.GITHUB_SHA as string;
Expand Down

0 comments on commit 9b90337

Please sign in to comment.