3

Want to trigger a GitHub Action (Repository B) from another GitHub Repository (A) via WebHook. So I try to configuring the WebHook on repository A but I can not specify the Authorization Header that is needed by GitHub Repository B.

Is this possible at all via WebHooks?

Both Repositories belong to the same Organization.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • Does this answer your question? [How to send data payload using http request to Github-Actions Workflow](https://stackoverflow.com/questions/70018912/how-to-send-data-payload-using-http-request-to-github-actions-workflow) – rethab Jun 01 '22 at 08:30
  • Many thanks for your respons!! Not really. Calling the remote workflow via a CURL call or even some pre configured actions is similar but not really the same. Advantage of WebHooks would be that we can dynamically add new URL's to be informed without having an action to do this. – cloud4every1 Jun 01 '22 at 11:04
  • Can you please show some sample code on what this should look like? – rethab Jun 01 '22 at 12:00
  • 1
    Would like to configure the WebHook under the source Repository -> settings -> WebHooks and enter the PayLoad URL with the value of my target Repository. On the target Repository I do have an Action that will be triggered (listening on repository_dispatch: ) But to make this POST request beeing accepted we do have to specify the header: "Authorization: bearer ". – cloud4every1 Jun 01 '22 at 12:40
  • Please update your question to show this in code/yaml. – rethab Jun 02 '22 at 05:51

1 Answers1

0

via WebHook

That means repo A WebHook URL is called, and your local endpoint (which listen to the wayhook payload) would need to receive a parameter representing the URL/name of repoB, which it then could curl -X POST in order to trigger its workflow (assuming you have the right token allowed to run API on repoB, in Authorization: bearer <token>).

Considering a webhook JSON payload for a push event include commit(s) message, I would push on repoA a commit with, in its message, the name or URL of repoB.
Your local webhook listener can then extract repoB, and tribber its workflow.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250