mirror of
https://github.com/garronej/ts-ci.git
synced 2025-11-30 21:43:05 +00:00
Follow up from https://github.com/garronej/github_actions_toolkit
This commit is contained in:
commit
5297ab00ab
54 changed files with 18162 additions and 0 deletions
47
src/dispatch_event.ts
Normal file
47
src/dispatch_event.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { getActionParamsFactory } from "./inputHelper";
|
||||
import { createOctokit } from "./tools/createOctokit";
|
||||
|
||||
export const { getActionParams } = getActionParamsFactory({
|
||||
"inputNameSubset": [
|
||||
"owner",
|
||||
"repo",
|
||||
"event_type",
|
||||
"client_payload_json",
|
||||
"github_token"
|
||||
] as const
|
||||
});
|
||||
|
||||
export type Params = ReturnType<typeof getActionParams>;
|
||||
|
||||
|
||||
type CoreLike = {
|
||||
debug: (message: string) => void;
|
||||
};
|
||||
|
||||
export async function action(
|
||||
_actionName: "dispatch_event",
|
||||
params: Params,
|
||||
core: CoreLike
|
||||
) {
|
||||
|
||||
const { owner, repo, event_type, client_payload_json, github_token } = params;
|
||||
|
||||
core.debug(JSON.stringify({ _actionName, params }));
|
||||
|
||||
|
||||
const octokit = createOctokit({ github_token });
|
||||
|
||||
await octokit.repos.createDispatchEvent({
|
||||
owner,
|
||||
repo,
|
||||
event_type,
|
||||
|
||||
...(!!client_payload_json ?
|
||||
{ "client_payload": JSON.parse(client_payload_json) } :
|
||||
{}
|
||||
)
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue