-
Notifications
You must be signed in to change notification settings - Fork 137
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
Add GitHub dispatch provider #369
Add GitHub dispatch provider #369
Conversation
Signed-off-by: Aleksey Pogibelev <aleksey.pogibelev@gmail.com>
Signed-off-by: Aleksey Pogibelev <aleksey.pogibelev@gmail.com>
internal/notifier/github_dispatch.go
Outdated
@@ -0,0 +1,121 @@ | |||
/* | |||
Copyright 2020 The Flux authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright 2020 The Flux authors | |
Copyright 2022 The Flux authors |
docs/spec/v1beta1/provider.md
Outdated
@@ -730,3 +732,141 @@ kubectl create secret generic webhook-url \ | |||
--from-literal=address="Endpoint=sb://fluxv2.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yoursaskeygeneatedbyazure" | |||
``` | |||
|
|||
### GitHub repository dispatch | |||
|
|||
The `githubdispatch` webhook triggers a GitHub webhook event called [`repository_dispatch`](https://docs.github.com/en/rest/reference/repos#create-a-repository-dispatch-event) for the selected repository. The `repository_dispatch` event can be used to trigger a GitHub Actions workflow with tests for the deployed service. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `githubdispatch` webhook triggers a GitHub webhook event called [`repository_dispatch`](https://docs.github.com/en/rest/reference/repos#create-a-repository-dispatch-event) for the selected repository. The `repository_dispatch` event can be used to trigger a GitHub Actions workflow with tests for the deployed service. | |
The `githubdispatch` provider generates GitHub events of type [`repository_dispatch`](https://docs.github.com/en/rest/reference/repos#create-a-repository-dispatch-event) for the selected repository. The `repository_dispatch` events can be used to trigger GitHub Actions workflow. |
docs/spec/v1beta1/provider.md
Outdated
|
||
The request includes the `event_type` and `client_payload` fields: | ||
|
||
* The `event_type` is generated by GitHub Dispatch provider by combining the Kind, Name and Namespace of the involved object in the format `{Kind}/{Name}.{Namespace}`. For example, the `event_type` for Flux configuration named `podinfo` in the `flux-system` namespace looks like this: `Kustomization/podinfo.flux-system` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The `event_type` is generated by GitHub Dispatch provider by combining the Kind, Name and Namespace of the involved object in the format `{Kind}/{Name}.{Namespace}`. For example, the `event_type` for Flux configuration named `podinfo` in the `flux-system` namespace looks like this: `Kustomization/podinfo.flux-system` | |
* The `event_type` is generated by GitHub Dispatch provider by combining the Kind, Name and Namespace of the involved object in the format `{Kind}/{Name}.{Namespace}`. For example, the `event_type` for a Flux Kustomization named `podinfo` in the `flux-system` namespace looks like this: `Kustomization/podinfo.flux-system`. |
docs/spec/v1beta1/provider.md
Outdated
|
||
* The `event_type` is generated by GitHub Dispatch provider by combining the Kind, Name and Namespace of the involved object in the format `{Kind}/{Name}.{Namespace}`. For example, the `event_type` for Flux configuration named `podinfo` in the `flux-system` namespace looks like this: `Kustomization/podinfo.flux-system` | ||
|
||
* The `client_payload` contains the event data from the notification controller and looks like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The `client_payload` contains the event data from the notification controller and looks like this: | |
* The `client_payload` contains the Kubernetes event issued by Flux, e.g.: |
docs/spec/v1beta1/provider.md
Outdated
|
||
#### Setting up a GitHub workflow | ||
|
||
You need to add `repository_dispatch` trigger to trigger your GitHub workflow using the Flux notification with the relevant event type: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To trigger a GitHub Actions workflow when a Flux Kustomization finishes reconciling, you need to set the event type on the repository_dispatch
to match the Flux object ID:
docs/spec/v1beta1/provider.md
Outdated
run: echo "running tests.." | ||
``` | ||
|
||
### Setting up the GitHub dispatch provider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this before "Setting up a GitHub workflow" please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Signed-off-by: Aleksey Pogibelev <aleksey.pogibelev@gmail.com>
Signed-off-by: Aleksey Pogibelev <aleksey.pogibelev@gmail.com>
56e350d
to
e320370
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @alekspog 🥇
Add support for GitHub repository dispatch provider.
Ref: fluxcd/flux2#2122
Fix: #329
Example of the notification message payload in the GitHub workflow