-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathtriggerCoreDnp.ts
More file actions
48 lines (44 loc) · 1.14 KB
/
triggerCoreDnp.ts
File metadata and controls
48 lines (44 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Github } from "../../../providers/github/Github";
import { readManifest } from "../../../utils/manifest";
import {
DNP_CORE_GITHUB_EVENT_TYPE,
DNP_CORE_GITHUB_USER,
DNP_CORE_GITHUB_REPO,
DNP_CORE_DEPENDENCIES
} from "../../../params";
/**
* Send a repository_dispatch event to the DNP_CORE Github repo only if:
* - Current package is a dependency of DNP_CORE
*/
export async function triggerCoreDnpWorkflowMaybe({
dir,
releaseMultiHash,
branch,
commitSha
}: {
dir: string;
releaseMultiHash: string;
branch: string;
commitSha: string;
}): Promise<void> {
const manifest = readManifest(dir);
if (!DNP_CORE_DEPENDENCIES.includes(manifest.name)) {
console.log(`Skipping triggerCoreDnpWorkflow for ${manifest.name}`);
return;
}
const github = new Github({
owner: DNP_CORE_GITHUB_USER,
repo: DNP_CORE_GITHUB_REPO
});
const clientPayload = {
releaseMultiHash,
branch,
commitSha
};
try {
await github.dispatchEvent(DNP_CORE_GITHUB_EVENT_TYPE, clientPayload);
console.log("Triggered DNP_CORE workflow");
} catch (e) {
console.log("Error on triggerCoreDnpWorkflow", e);
}
}