Skip to content

Commit 56e350d

Browse files
committed
fix documentation
1 parent f54e6f7 commit 56e350d

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

docs/spec/v1beta1/provider.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -734,13 +734,13 @@ kubectl create secret generic webhook-url \
734734

735735
### GitHub repository dispatch
736736

737-
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.
737+
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.
738738

739739
The request includes the `event_type` and `client_payload` fields:
740740

741-
* 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`
741+
* 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`.
742742

743-
* The `client_payload` contains the event data from the notification controller and looks like this:
743+
* The `client_payload` contains the Kubernetes event issued by Flux, e.g.:
744744

745745
```yaml
746746
{
@@ -765,9 +765,42 @@ The request includes the `event_type` and `client_payload` fields:
765765
}
766766
```
767767

768+
### Setting up the GitHub dispatch provider
769+
770+
```yaml
771+
apiVersion: notification.toolkit.fluxcd.io/v1beta1
772+
kind: Provider
773+
metadata:
774+
name: github-dispatch
775+
namespace: flux-system
776+
spec:
777+
type: githubdispatch
778+
address: https://github.com/stefanprodan/podinfo
779+
secretRef:
780+
name: api-token
781+
```
782+
783+
The `address` is the address of your repository where you want to send webhooks to trigger GitHub workflows.
784+
785+
GitHub uses personal access tokens for authentication with its API:
786+
787+
* [GitHub personal access token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token)
788+
789+
The provider requires a secret in the same format, with the personal access token as the value for the token key:
790+
791+
```yaml
792+
apiVersion: v1
793+
kind: Secret
794+
metadata:
795+
name: api-token
796+
namespace: default
797+
data:
798+
token: <personal-access-tokens>
799+
```
800+
768801
#### Setting up a GitHub workflow
769802

770-
You need to add `repository_dispatch` trigger to trigger your GitHub workflow using the Flux notification with the relevant event type:
803+
To trigger a GitHub Actions workflow when a Flux Kustomization finishes reconciling, you need to set the event type for the repository_dispatch trigger to match the Flux object ID:
771804

772805
```yaml
773806
name: test-github-dispatch-provider
@@ -822,7 +855,7 @@ spec:
822855
name: 'podinfo'
823856
```
824857

825-
Now you can the trigger tests in the GitHub workflow for app1 in a staging cluster when the app1 resources defined in `./app1/staging/` are configured by Flux:
858+
Now you can the trigger tests in the GitHub workflow for app1 in a staging cluster when the app1 resources defined in `./app1/staging/` are reconciled by Flux:
826859

827860
```yaml
828861
name: test-github-dispatch-provider
@@ -837,36 +870,3 @@ jobs:
837870
- name: Run tests
838871
run: echo "running tests.."
839872
```
840-
841-
### Setting up the GitHub dispatch provider
842-
843-
```yaml
844-
apiVersion: notification.toolkit.fluxcd.io/v1beta1
845-
kind: Provider
846-
metadata:
847-
name: github-dispatch
848-
namespace: flux-system
849-
spec:
850-
type: githubdispatch
851-
address: https://github.com/stefanprodan/podinfo
852-
secretRef:
853-
name: api-token
854-
```
855-
856-
The `address` is the address of your repository where you want to send webhooks to trigger GitHub workflows.
857-
858-
GitHub uses personal access tokens for authentication with its API:
859-
860-
* [GitHub personal access token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token)
861-
862-
The provider requires a secret in the same format, with the personal access token as the value for the token key:
863-
864-
```yaml
865-
apiVersion: v1
866-
kind: Secret
867-
metadata:
868-
name: api-token
869-
namespace: default
870-
data:
871-
token: <personal-access-tokens>
872-
```

internal/notifier/github_dispatch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2020 The Flux authors
2+
Copyright 2022 The Flux authors
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)