feat: actually sync repos
All checks were successful
Build and Push Docker Image / build (push) Successful in 13s
All checks were successful
Build and Push Docker Image / build (push) Successful in 13s
This commit is contained in:
@@ -2,6 +2,7 @@ import express from "express";
|
|||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { env } from "./env";
|
import { env } from "./env";
|
||||||
|
import { syncGiteaRewrites } from "./sync";
|
||||||
|
|
||||||
const webhookSchema = z.object({
|
const webhookSchema = z.object({
|
||||||
action: z.enum(["deleted", "created"]),
|
action: z.enum(["deleted", "created"]),
|
||||||
@@ -45,7 +46,11 @@ app.post("/", async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { action } = result.data;
|
const { action } = result.data;
|
||||||
console.log(`Webhook received: ${action}`);
|
console.log(`Received event: ${action}`);
|
||||||
|
|
||||||
|
console.log("Synchronizing...");
|
||||||
|
const repos = await syncGiteaRewrites();
|
||||||
|
console.log(`Done (${repos.length}): ${repos.join(", ")}`);
|
||||||
|
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
});
|
});
|
||||||
@@ -53,3 +58,5 @@ app.post("/", async (req, res) => {
|
|||||||
app.listen(env.PORT, () => {
|
app.listen(env.PORT, () => {
|
||||||
console.log(`Server running on port ${env.PORT}`);
|
console.log(`Server running on port ${env.PORT}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await syncGiteaRewrites();
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ const createOutputFile = async (repos: string[]): Promise<void> => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const syncGiteaRewrites = async (): Promise<void> => {
|
export const syncGiteaRewrites = async (): Promise<string[]> => {
|
||||||
const repos = await fetchGiteaRepos();
|
const repos = await fetchGiteaRepos();
|
||||||
await createOutputFile(repos);
|
await createOutputFile(repos);
|
||||||
|
return repos;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user