Skip to content

Commit

Permalink
Update GitHub and Flux docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok committed Aug 11, 2023
1 parent e6b803e commit c0b71bb
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
34 changes: 34 additions & 0 deletions docs/configuration/source/github-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,29 @@ By default, we use [conditional requests](https://docs.github.com/en/rest/overvi

For a configured `refreshDuration` we call the [`/repos/{owner}/{repo}/pulls`](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests) endpoint for all registered repositories. It's configured to fetch 100 pull requests that were recently modified. We ignore all events that were already processed.

#### Matching criteria

If no matching criteria are specified, all pull requests will be reported. For example:

```yaml
repositories:
- name: owner/repo1
on:
pullRequests: []
```

To narrow down emitted events, you can specify at least one of the available criteria:

- `types`: This is a list of pull request types for which the event should be triggered. The allowed types are: `open`, `closed`, `merged`.

- `paths.include`: This is a list of file patterns for which the event should be triggered. It supports [Go regular expressions](https://github.com/google/re2/wiki/Syntax). For example: `["kustomize/.*"]`.

- `paths.exclude`: This is a list of file patterns for which the event should not be triggered. It also supports [Go regular expressions](https://github.com/google/re2/wiki/Syntax). For example: `['.*\.js']`. This exclusion criteria takes precedence over `paths.include`.

- `labels.include`: This is a list of label patterns for which the event should be triggered. It supports [Go regular expressions](https://github.com/google/re2/wiki/Syntax). For example: `["backend-.*"]`.

- `labels.exclude`: This is a list of label patterns for which the event should not be triggered. It supports [Go regular expressions](https://github.com/google/re2/wiki/Syntax). For example: `['bug']`. This exclusion criteria takes precedence over `labels.include`.

#### Templating

You can customize the notification template with additional buttons:
Expand All @@ -187,6 +210,17 @@ This API is not built to serve real-time use cases. Depending on the time of day

The Events API covers various event types. Refer to the [GitHub event types](https://docs.github.com/en/webhooks-and-events/events/github-event-types) page for more information.

#### Matching criteria

To retrieve relevant events, you must define at least one entry within the `events` property. For instance:

```yaml
events:
- type: "WatchEvent"
```

If you provide an empty list `events: []`, no events will be emitted.

#### Templating

The available fields for templating differ based on the event type. Refer to the [google/go-github](https://github.com/google/go-github/tree/899235e0a9d750d6fecf9048a676046d50f9d4a3/github) repository for dedicated event types.
Expand Down
49 changes: 48 additions & 1 deletion docs/usage/executor/flux.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ title: "Flux"
sidebar_position: 5
---

Botkube offers seamless execution of Flux CLI commands within your Kubernetes cluster. By default, Flux command execution is disabled. To enable it, refer to the [**Enabling plugin**](../../configuration/executor/flux.md#enabling-plugin) section.
Botkube offers seamless execution of Flux CLI commands within your Kubernetes cluster. By default, Flux command execution is disabled. To enable it, refer to the [
**Enabling plugin**](../../configuration/executor/flux.md#enabling-plugin) section.

To execute the `flux` CLI commands, send a message in the channel where Botkube is present. For example:

Expand Down Expand Up @@ -87,3 +88,49 @@ extraObjects:
name: flux-read-patch
apiGroup: rbac.authorization.k8s.io
```
### GitHub automation
To enhance your workflow's efficiency, you can use the [GitHub Events](../../configuration/source/github-events.md) source for automatic notification of pull request events, complete with an integrated `flux diff` button.

```yaml
sources:
github-events:
displayName: "GitHub Events"
botkube/github-events:
enabled: true
config:
github:
auth:
accessToken: "ghp_" # GitHub PAT
repositories:
- name: { owner }/{name}
on:
pullRequests:
- types: [ "open" ]
paths:
# Patterns for included file changes in pull requests.
include: [ 'kustomize/.*' ]
notificationTemplate:
extraButtons:
- displayName: "Flux Diff"
commandTpl: "flux diff ks podinfo --path ./kustomize --github-ref {{ .HTMLURL }} "
```

Don't forget to incorporate the `github-events` source into your communication platform bindings. For instance:

```yaml
communications:
default-group:
socketSlack:
enabled: true
channels:
default:
name: random
bindings:
sources:
- github-events
executors:
- flux
```

0 comments on commit c0b71bb

Please sign in to comment.