feat(prd-6): verify workflow triggers and add assignee_trigger (#13)

This commit is contained in:
Vlad Mocanu committed 2026-02-25 21:43:37 +00:00
1 parent 095c2c2429
commit a129a15f61
5 files changed
+71 -19

No files matched your search

+15 -1
View File
@@ -60,6 +60,18 @@ const ENTITY_EVENT_NAMES = [
"pull_request_review_comment",
] as const;
/**
* Forgejo uses different event names for some webhook events.
* Normalize to GitHub-canonical names so all downstream code works unchanged.
*/
const FORGEJO_EVENT_NAME_MAP: Record<string, string> = {
pull_request_comment: "pull_request_review_comment",
};
function normalizeEventName(eventName: string): string {
return FORGEJO_EVENT_NAME_MAP[eventName] ?? eventName;
}
const AUTOMATION_EVENT_NAMES = [
"workflow_dispatch",
"repository_dispatch",
@@ -132,6 +144,8 @@ export type GitHubContext = ParsedGitHubContext | AutomationContext;
export function parseGitHubContext(): GitHubContext {
const context = github.context;
// Normalize Forgejo event names to GitHub-canonical equivalents
const eventName = normalizeEventName(context.eventName);
const commonFields = {
runId: process.env.GITHUB_RUN_ID!,
@@ -165,7 +179,7 @@ export function parseGitHubContext(): GitHubContext {
},
};
switch (context.eventName) {
switch (eventName) {
case "issues": {
const payload = context.payload as IssuesEvent;
return {
+11 -2
View File
@@ -2,6 +2,15 @@ import fs from "fs/promises";
import path from "path";
import type { Octokits } from "../api/client";
// Mutable fs reference for cross-platform test compatibility.
// On Linux, Bun gives test and source files different fs/promises objects,
// so spyOn(fs, "mkdir") in a test file won't intercept calls here.
// Tests override these methods directly instead.
export const _fsForTest = {
mkdir: fs.mkdir.bind(fs),
writeFile: fs.writeFile.bind(fs),
};
// Build regexes at call time, reading GITHUB_SERVER_URL from process.env
// directly. The config.ts export freezes the value at module load time,
// which can be wrong when the Forgejo CI runner injects its own
@@ -67,7 +76,7 @@ export async function downloadCommentImages(
const urlToPathMap = new Map<string, string>();
const downloadsDir = "/tmp/github-images";
await fs.mkdir(downloadsDir, { recursive: true });
await _fsForTest.mkdir(downloadsDir, { recursive: true });
const { imageRegex, htmlImgRegex } = buildImageRegexes();
@@ -217,7 +226,7 @@ export async function downloadCommentImages(
const arrayBuffer = await imageResponse.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
await fs.writeFile(localPath, buffer);
await _fsForTest.writeFile(localPath, buffer);
console.log(`✓ Saved: ${localPath}`);
urlToPathMap.set(originalUrl, localPath);