add git pull path
This commit is contained in:
parent
ee67722526
commit
8839141f16
1 changed files with 22 additions and 1 deletions
21
index.ts
21
index.ts
|
|
@ -256,6 +256,27 @@ Bun.serve({
|
||||||
new ClientResponse(req, await fs.readFile("artists.ndjson")),
|
new ClientResponse(req, await fs.readFile("artists.ndjson")),
|
||||||
"/th_artists.ndjson": async (req) =>
|
"/th_artists.ndjson": async (req) =>
|
||||||
new ClientResponse(req, await fs.readFile("th_artists.ndjson")),
|
new ClientResponse(req, await fs.readFile("th_artists.ndjson")),
|
||||||
|
"/git-pull": async (req) => {
|
||||||
|
const authFail = requireBasicAuth(req);
|
||||||
|
if (authFail) return authFail;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const pull = await $`git pull origin main`.nothrow();
|
||||||
|
const output = `${pull.stdout}${pull.stderr}`;
|
||||||
|
|
||||||
|
if (pull.exitCode !== 0) {
|
||||||
|
return new ClientResponse(req, `Git pull failed: ${output}`, {
|
||||||
|
status: 500,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ClientResponse(req, `Git pull successful: ${output}`);
|
||||||
|
} catch (err) {
|
||||||
|
return new ClientResponse(req, `Error during git pull: ${err}`, {
|
||||||
|
status: 500,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
"/ignore-th/:id": async (req) => {
|
"/ignore-th/:id": async (req) => {
|
||||||
const authFail = requireBasicAuth(req);
|
const authFail = requireBasicAuth(req);
|
||||||
if (authFail) return authFail;
|
if (authFail) return authFail;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue