Skip to content

Commit

Permalink
refactor: add more detail to webhook responses
Browse files Browse the repository at this point in the history
These webhook responses are visible in GitHub's UI and help with debugging, so let's add some detail on why no action was taken.
  • Loading branch information
masonmcelvain committed Sep 20, 2024
1 parent 5c39db9 commit db583a2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/routes/github.webhook/pull-request-webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ export async function processPullRequestWebhook(
repository: Repository
) {
if (!repository.deployOnlyOnPullRequest)
return json({ message: "No action taken" });
return json({ message: "No action taken (deploy only on pull request)" });

const [files, branch] = await findPullRequestData();

if (!branch && !hasChangesAffectingNextjsApp())
return json({ message: "No action taken" });
return json({
message:
"No action taken (no branch or no changes found in `apps/`, `packages/` or `.github/workflows/nextjs-deploy-nextjs.yml`)",
});

switch (webhook.payload.action) {
case "opened":
Expand All @@ -31,7 +34,9 @@ export async function processPullRequestWebhook(
return json({ message: `Deleting branch "${branchName()}"` });
}
default:
return json({ message: "No action taken" });
return json({
message: `No action taken for webhook payload action ${webhook.payload.action}`,
});
}

function findPullRequestData() {
Expand Down

0 comments on commit db583a2

Please sign in to comment.