Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
Don't run automatically on commit (#56)
Browse files Browse the repository at this point in the history
Only manually.

No more webhooks means:
- Closes #34 
- Closes #42
  • Loading branch information
yardenshoham authored Feb 28, 2023
1 parent f7ab35d commit 09004ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 27 deletions.
16 changes: 0 additions & 16 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,3 @@ export const addBackportDoneLabel = async (prNumber: number) => {
}`,
);
};

// trigger GitHub action using workflow_dispatch
export const triggerBackportAction = async () => {
const response = await fetch(
`${GITHUB_API}/repos/yardenshoham/gitea-backporter/actions/workflows/backport.yml/dispatches`,
{
method: "POST",
headers: HEADERS,
body: JSON.stringify({ ref: "main" }),
},
);
if (!response.ok) {
throw new Error(`Failed to trigger backport action: ${response.status}`);
}
console.log(`Triggered backport action`);
};
14 changes: 3 additions & 11 deletions src/webhook.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { serve } from "https://deno.land/std@0.178.0/http/server.ts";
import { triggerBackportAction } from "./github.ts";

if (Deno.env.get("BACKPORTER_GITHUB_TOKEN") === undefined) {
console.error("BACKPORTER_GITHUB_TOKEN is not set");
}

serve(async (req: Request) => {
if (req.url.endsWith("/trigger")) {
await triggerBackportAction();
return Response.json({ message: "Triggered backport" });
} else {
return Response.json({ status: "OK" });
}
const json = await req.json();
console.log(json);
return Response.json({ status: "OK" });
});

0 comments on commit 09004ba

Please sign in to comment.