-
-
Notifications
You must be signed in to change notification settings - Fork 324
Enhanced GitHub webhooks: support for secrets and for more events #1207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
W95Psp
wants to merge
7
commits into
NixOS:master
Choose a base branch
from
W95Psp:enhanced-github-webhooks
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6d4c53b
Add `webhook-github` endpoint, redirect and deprecate `push-github`
W95Psp 2af4e36
Support for secure GitHub webhook payloads (Fixes NixOS/hydra#333)
W95Psp aca2dac
Whitelist `webhook-github` path
W95Psp cf06809
more documentation for GitHub webhooks
W95Psp 23019a7
Add X-GitHub-Event headers in API tests
W95Psp cb0ee7e
GitHub username: use `login` key in addition to `name` key
W95Psp c54866f
Convert tabs to spaces
W95Psp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,40 @@ | ||
| # Webhooks | ||
|
|
||
| Hydra can be notified by github's webhook to trigger a new evaluation when a | ||
| jobset has a github repo in its input. | ||
| To set up a github webhook go to `https://github.com/<yourhandle>/<yourrepo>/settings` and in the `Webhooks` tab | ||
| ## GitHub | ||
| Hydra can be notified by GitHub's webhook to trigger a new evaluation when a | ||
| jobset has a GitHub repo in its input. | ||
|
|
||
| GitHub's webhook can be triggered on [various events](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads). Hydra recognizes the following events. | ||
|
|
||
| - [`push`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push): triggers a new evaluation for every jobset that have the GitHub repository as a "Git Checkout" input. | ||
| - [`create`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#create) and [`delete`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#deleta): triggers a new evaluation for every jobset that have the GitHub repository as a "github_refs" input. | ||
| - [`pull_request`](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request): triggers a new evaluation for every jobset that have the GitHub repository as a "githubpulls" input. | ||
|
|
||
| ### Guide | ||
|
|
||
| To set up a GitHub webhook go to `https://github.com/<yourhandle>/<yourrepo>/settings` and in the `Webhooks` tab | ||
| click on `Add webhook`. | ||
|
|
||
| - In `Payload URL` fill in `https://<your-hydra-domain>/api/push-github`. | ||
| - In `Payload URL` fill in `https://<your-hydra-domain>/api/webhook-github`. | ||
| - In `Content type` switch to `application/json`. | ||
| - The `Secret` field can stay empty. | ||
| - For `Which events would you like to trigger this webhook?` keep the default option for events on `Just the push event.`. | ||
| - The `Secret` field can stay empty (see below to configure a secret). | ||
| - For `Which events would you like to trigger this webhook?` either keep the default option, or select the ones you are interested in (see above for the supported events). | ||
|
|
||
| Then add the hook with `Add webhook`. | ||
|
|
||
| ### Securing GitHub's webhooks | ||
| Secrets for webhooks can be configured by adding `github_webhook` keys in your Hydra configuration. | ||
| Each `github_webhook` provides a secret (`secret`, a string) for a certain range of repository name (`repo`, a regex) and repository owner (`owner`, a regex). | ||
|
|
||
| For instance below we declare one secret, `foo`, for the repositories whose owner is `someone` or `someother` and is named `somerepo`. | ||
|
|
||
| **IMPORTANT**: note that secrets should **never** be included directly in your `hydra.conf`, otherwise they will be exposed in plain text in the store. Instead, use includes [as described here](./configuration.html#including-files). | ||
|
|
||
| ```xml | ||
| <github_webhook> | ||
| owner = (someone|someother) | ||
| repo = somerepo | ||
| secret = foo | ||
| </github_webhook> | ||
| ``` | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.