mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +00:00
feat(github): fetch workflow_run jobs via jobs_url enrichment
The workflow_run webhook payload carries no jobs array, only jobs_url, so the Jobs field never populated for real GitHub events. Fetch the job list from the GitHub API once per delivery (lazy, memoized across routes) and inject it into the payload before formatting. - app-token.ts: shared getInstallationToken (App JWT -> installation token) + GITHUB_API_VERSION; check-run.ts now reuses it - workflow-jobs.ts: getWorkflowRunJobs, App token when configured else unauthenticated (public repos), per_page=100, best-effort - docs: GitHub App needs Actions: read; note API enrichment in the message-format and supported-events guides (en + zh)
This commit is contained in:
12 files changed
+223
-23
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import { createAppJwt } from "./oauth";
|
||||
import { getInstallationToken, GITHUB_API_VERSION } from "./app-token";
|
||||
|
||||
const API_VERSION = "2022-11-28";
|
||||
const CLOUDFLARE_SLUG = "cloudflare-workers-and-pages";
|
||||
|
||||
/**
|
||||
@@ -21,27 +20,14 @@ export async function getCheckSuiteBuildLogUrl(
|
||||
): Promise<string | undefined> {
|
||||
if (!checkRunsUrl || !appId || !privateKey || !installationId) return undefined;
|
||||
try {
|
||||
const jwt = await createAppJwt(appId, privateKey);
|
||||
const tokRes = await fetch(
|
||||
`https://api.github.com/app/installations/${installationId}/access_tokens`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${jwt}`,
|
||||
Accept: "application/vnd.github+json",
|
||||
"X-GitHub-Api-Version": API_VERSION,
|
||||
},
|
||||
},
|
||||
);
|
||||
if (!tokRes.ok) return undefined;
|
||||
const { token } = (await tokRes.json()) as { token?: string };
|
||||
const token = await getInstallationToken(appId, privateKey, installationId);
|
||||
if (!token) return undefined;
|
||||
|
||||
const runsRes = await fetch(checkRunsUrl, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
Accept: "application/vnd.github+json",
|
||||
"X-GitHub-Api-Version": API_VERSION,
|
||||
"X-GitHub-Api-Version": GITHUB_API_VERSION,
|
||||
},
|
||||
});
|
||||
if (!runsRes.ok) return undefined;
|
||||
|
||||
Reference in new issue
Block a user