Webhook for Github

Hello,

I'm trying to set up a webhook that will trigger a github action. The github action builds and deploys my side. I've followed the instructions in these two posts:

-Using webhooks to fire Github action - #6 by Fares
-Setting Authorization Header in Webhooks

Still getting a 404 or 422 error. I noticed that the payload comes from prismic with event type rather than event_type, is that what is causing it?

Just pulling my hair out trying to get this to work. If anyone has done it before and might no where I am going wrong, I would really appreciate the help. I'm trying to follow the steps in the two articles above but keep getting that error when I test out the webhook.

Thanks,
-Conner

Hey Conner,

What did you set the 'key' and 'value' for your headers in Primsic as?

Thanks.

I've also just been playing with this same workflow. Unfortunately it looks like the prismic payload isn't compatible with the current Github dispatch endpoint :frowning:

It's not just the mismatch between type and event_type, github also won't accept secret, and other extra fields…

Welcome to the community, Daniel.

Thanks for the extra info, I'm going to report this to the team as a Request For Change, if/when we have any updates we'll let you know here.

2 Likes

This is an issue that I was tracking for around 1.5years in Prismic. I saw many requests on this topic from various users. I send the same in feedback email as well. I still don't see any solutions.

Is it something Prismic planning to do? Is there any realistic timeline?

Thanks,
Subin

Hi @subin01,

We are tracking this in our backlog, but due to other high-priority tasks, we cannot get to it just yet. We will of course provide you with an update as soon as possible.

Thanks.

2 Likes

@Phil Any update on this issue?

Hi @nishuarora.nishant,

This is still being tracked as a feature request, but there has been no movement in terms of priority.

Thanks.

@Phil what about now? There are threads going back 3 years at least asking about custom bodies for webhooks — a necessary feature to trigger GitHub actions.

Any chance this sees the light of day in 2023?

Hello @wyatt and others,

Thanks a lot for your suggestions for enhancements. While we don't have immediate plans to incorporate this feature, many of our users have found a viable alternative.

With the growing trend towards serverless architecture, you can achieve payload customization using a proxy function. Below is a sample code snippet that demonstrates how to accomplish this with a serverless function in Vercel.

import type { VercelRequest, VercelResponse } from "@vercel/node";

const OWNER = "owner";
const REPO = "repo";
const WORKFLOW_ID = "workflowID";

export default async function handler(request: VercelRequest, response: VercelResponse) {
  if (request.body.secret !== process.env.GITHUB_WEBHOOK_SECRET) {
    return response.status(401).send({ error: "Unauthorized access" });
  }

  const res = await fetch(
    `https://api.github.com/repos/${OWNER}/${REPO}/actions/workflows/${WORKFLOW_ID}/dispatches`,
    {
      method: "POST",
      body: JSON.stringify({
        ref: "master",
        inputs: {
          body: request.body,
        },
      }),
      headers: {
        Accept: "application/vnd.github+json",
        Authorization: `Bearer ${process.env.GITHUB_ACCESS_TOKEN}`,
        "X-GitHub-Api-Version": "2022-11-28",
      },
    }
  );

  if (res.ok) {
    return response.status(204).send({ success: true });
  } else {
    return response.status(400).send({ error: "Webhook forwarding failed" });
  }
}

I hope that you'll find this workaround useful.

Cheers,

Thanks @renaud, the sample implementation is useful — but I will say that expecting users to run, maintain, and pay for additional infrastructure just to make webhooks work with an extremely common CI provider is preeeeeeetttty lame from a product standpoint.

1 Like

Is running a lambda function still the suggestion here? Ran into this issue today (Dec 19, 2025) and came across this post from 2 years ago.

Hey @amacpherson, we do still recommend having a proxy between Prismic and Github for the time being. We're aware of the user need for this and have an open feature request for it, thanks for adding your voice to it!

it might be useful to someone. Implementation via cloudflare workers:

export default {
async fetch(request, env) {
if (request.method !== 'POST') {
return new Response('Method not allowed', { status: 405 });
}

try {
  // Логируем наличие токена (без раскрытия)
  console.log('GH_PAT present:', !!env.GH_PAT);

  const githubResponse = await fetch(
    `https://api.github.com/repos/"YOUREPO"/dispatches`,
    {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${env.GH_PAT}`,
        'Accept': 'application/vnd.github.v3+json',
        'Content-Type': 'application/json',
        'User-Agent': 'Cloudflare-Worker'
      },
      body: JSON.stringify({
        event_type: 'prismic-update',
      }),
    }
  );

  const responseStatus = githubResponse.status;
  const responseBody = await githubResponse.text();
  console.log('GitHub response status:', responseStatus);
  console.log('GitHub response body:', responseBody);

  if (!githubResponse.ok) {
    throw new Error(`GitHub responded with ${responseStatus}: ${responseBody}`);
  }

  return new Response(JSON.stringify({ success: true }), {
    headers: { 'Content-Type': 'application/json' },
  });
} catch (error) {
  console.error('Error:', error);
  return new Response(JSON.stringify({ error: error.message }), {
    status: 500,
    headers: { 'Content-Type': 'application/json' },
  });
}

},
};

Secrets in dash.cloudflare: GH_PAT=yousecret,PRISMIC_WEBHOOK_SECRET=yousecret

astro.yml on githubActions:


Sample workflow for building and deploying an Astro site to GitHub Pages



To get started with Astro see: 




name: Deploy Astro site to Pages

on:

Runs on pushes targeting the default branch

push:
branches: ["main"]

Allows you to run this workflow manually from the Actions tab

workflow_dispatch:

Triggered by repository_dispatch from Cloudflare Worker

repository_dispatch:
types: [prismic-update]   # должно совпадать с event_type из Worker'а

Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages

permissions:
contents: read
pages: write
id-token: write

Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.

However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.

concurrency:
group: "pages"
cancel-in-progress: false

env:
BUILD_PATH: "." # default value when not using subfolders

BUILD_PATH: subfolder

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }}
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
working-directory: ${{ env.BUILD_PATH }}
- name: Build with Astro
run: |
${{ steps.detect-package-manager.outputs.runner }} astro build 
--site "${{ steps.pages.outputs.origin }}" 
--base "${{ steps.pages.outputs.base_path }}"
working-directory: ${{ env.BUILD_PATH }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ env.BUILD_PATH }}/dist

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

create Personal access tokens (classic) + repo in GitHub for cloudflare workers

1 Like