Skip to content

Commit

Permalink
feat(api): support re-running checks
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop committed May 31, 2024
1 parent b3b3512 commit 2575c53
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 16 deletions.
31 changes: 23 additions & 8 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
WorkflowInputs,
WorkflowRun
} from '@/types';
import { wait } from '@/utils';
import { wait, sourceHtml } from '@/utils';

/**
* API wrapper for the fork action and related usages.
Expand Down Expand Up @@ -145,7 +145,8 @@ export default class Api {
status: 'in_progress',
output: {
title: name,
summary: `Forked from ${run.html_url}`
summary: `Forked from ${run.html_url}\n
Rerun the check in ${sourceHtml()} to re-trigger this check.`
},
head_sha
});
Expand Down Expand Up @@ -267,7 +268,15 @@ export default class Api {
);
});

return runs[0];
const workflow = runs[0];

// Here we allows re-trigger a new workflow if the previous one
// is completed and not success.
if (workflow.status === 'completed' && workflow.conclusion === 'failure') {
return undefined;
}

return workflow;
}

/**
Expand Down Expand Up @@ -299,11 +308,7 @@ export default class Api {
repo: this.repo,
check_run_id,
status,
conclusion,
output: {
title: job.name,
summary: `Forked from ${job.html_url}`
}
conclusion
});

return data;
Expand Down
14 changes: 14 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,17 @@ function deriveInputs(): IInputsAndJobs {
jobs
};
}

export function sourceHtml(): string {
const context = github.context;
const html =
context.serverUrl +

Check failure on line 95 in src/utils.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected string concatenation

Check failure on line 95 in src/utils.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Unexpected string concatenation
'/' +
context.repo.owner +
'/' +
context.repo.repo +
'/actions/runs/' +
context.runId;

return html;
}

0 comments on commit 2575c53

Please sign in to comment.