@cloud-cli/on 1.59.0 → 1.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/db-client-BvMkK1lx.js +8 -0
- package/dist/db-client.d.ts +10 -16
- package/dist/db-client.d.ts.map +1 -1
- package/dist/events-BoODn7MY.js +56 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/matrix-expander-BItKqWu2.js +3439 -0
- package/dist/oidc.d.ts +39 -0
- package/dist/oidc.d.ts.map +1 -0
- package/dist/on.js +76 -22512
- package/dist/queue-DhXXzxm3.js +200 -0
- package/dist/rolldown-runtime-B0aSnxlc.js +20 -0
- package/dist/scheduler-2d1UPcxM.js +96 -0
- package/dist/secrets-BR6K16WY.js +30 -0
- package/dist/secrets-DhkqmawU.js +2 -0
- package/dist/server-CpHe08Nv.js +13445 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/timestamped-log-Dtz_Euu0.js +36 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/worker-riimPLUr.js +895 -0
- package/dist/workflow-registry-D4IciIF7.js +61 -0
- package/dist/workflows-BF2K4GpM.js +2 -0
- package/dist/workflows-Dm_0dWb_.js +4472 -0
- package/package.json +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//#region src/plugins/github-status.plugin.ts
|
|
2
|
+
var e = class {
|
|
3
|
+
name = "github-commit-status";
|
|
4
|
+
token;
|
|
5
|
+
apiUrl;
|
|
6
|
+
context;
|
|
7
|
+
constructor(e) {
|
|
8
|
+
this.token = e.token, this.apiUrl = e.apiUrl || "https://api.github.com/", this.context = e.context || "on";
|
|
9
|
+
}
|
|
10
|
+
async onWorkflowStart(e) {
|
|
11
|
+
this.hasCoordinates(e) && await this.updateStatus(e, "pending", "Workflow build has started.");
|
|
12
|
+
}
|
|
13
|
+
async onWorkflowFinish(e, t) {
|
|
14
|
+
if (!this.hasCoordinates(e)) return;
|
|
15
|
+
let n = t === "success" ? "success" : t === "failed" ? "failure" : "error", r = t === "success" ? "Workflow completed successfully." : `Workflow ${t}.`;
|
|
16
|
+
await this.updateStatus(e, n, r);
|
|
17
|
+
}
|
|
18
|
+
async updateStatus(e, t, n) {
|
|
19
|
+
let r = encodeURIComponent(String(e.inputs.owner)), i = encodeURIComponent(String(e.inputs.repo)), a = encodeURIComponent(String(e.inputs.commit_sha)), o = this.apiUrl.endsWith("/") ? this.apiUrl : `${this.apiUrl}/`, s = await fetch(new URL(`repos/${r}/${i}/statuses/${a}`, o), {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: {
|
|
22
|
+
Accept: "application/vnd.github+json",
|
|
23
|
+
Authorization: `Bearer ${this.token}`,
|
|
24
|
+
"Content-Type": "application/json",
|
|
25
|
+
"User-Agent": "@cloud-cli/on",
|
|
26
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
27
|
+
},
|
|
28
|
+
signal: AbortSignal.timeout(1e4),
|
|
29
|
+
body: JSON.stringify({
|
|
30
|
+
state: t,
|
|
31
|
+
target_url: e.runUrl,
|
|
32
|
+
description: n.slice(0, 140),
|
|
33
|
+
context: `${this.context}/${e.workflowName}`.slice(0, 100)
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
if (!s.ok) throw Error(`GitHub status update failed with HTTP ${s.status}: ${await s.text()}`);
|
|
37
|
+
}
|
|
38
|
+
hasCoordinates(e) {
|
|
39
|
+
return !!(this.token && e.inputs.owner && e.inputs.repo && e.inputs.commit_sha);
|
|
40
|
+
}
|
|
41
|
+
}, t = /* @__PURE__ */ new Map();
|
|
42
|
+
function n(e, n) {
|
|
43
|
+
if (!e.trim()) throw Error("Workflow plugin name is required");
|
|
44
|
+
t.set(e, n);
|
|
45
|
+
}
|
|
46
|
+
function r(e) {
|
|
47
|
+
let n = t.get(e.name);
|
|
48
|
+
if (!n) throw Error(`Unknown workflow plugin '${e.name}'`);
|
|
49
|
+
return n(e);
|
|
50
|
+
}
|
|
51
|
+
n("github-status", (t) => {
|
|
52
|
+
let n = t.secrets.GITHUB_TOKEN || t.secrets.token;
|
|
53
|
+
if (!n) throw Error("Plugin 'github-status' requires a GITHUB_TOKEN secret mapping");
|
|
54
|
+
return new e({
|
|
55
|
+
token: n,
|
|
56
|
+
context: t.context,
|
|
57
|
+
apiUrl: t.apiUrl
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
//#endregion
|
|
61
|
+
export { n, e as r, r as t };
|