fix: repair gitea github webhook sync egress
This commit is contained in:
@@ -56,7 +56,7 @@ createServer(async (req, res) => {
|
||||
running.add(repo.key);
|
||||
try {
|
||||
const sync = syncRepository(repo);
|
||||
log({ event: "github-to-gitea-sync", repo: repo.key, ok: sync.ok, sourceCommit: sync.sourceCommit, snapshotRef: sync.snapshotRef, elapsedMs: Date.now() - startedAt, valuesPrinted: false });
|
||||
log({ event: "github-to-gitea-sync", repo: repo.key, ok: sync.ok, sourceCommit: sync.sourceCommit, snapshotRef: sync.snapshotRef, error: sync.error ? redact(sync.error) : null, elapsedMs: Date.now() - startedAt, valuesPrinted: false });
|
||||
writeJson(res, sync.ok ? 200 : 500, { ok: sync.ok, event, repository, ref, repo: repo.key, ...sync, valuesPrinted: false });
|
||||
} finally {
|
||||
running.delete(repo.key);
|
||||
@@ -136,6 +136,13 @@ function log(payload) {
|
||||
console.log(JSON.stringify(payload));
|
||||
}
|
||||
|
||||
function redact(value) {
|
||||
return String(value || "")
|
||||
.replace(/Authorization: Basic [A-Za-z0-9+/=]+/gu, "Authorization: Basic <redacted>")
|
||||
.replace(/x-access-token:[^@\s]+/gu, "x-access-token:<redacted>")
|
||||
.slice(-1600);
|
||||
}
|
||||
|
||||
function requiredEnv(name) {
|
||||
const value = process.env[name];
|
||||
if (!value) throw new Error(`missing env ${name}`);
|
||||
|
||||
Reference in New Issue
Block a user