Skip to content

Commit 43d9d39

Browse files
authored
Merge pull request #125 from fluxcd/push-to-branch-doc
Explain how the push field works
2 parents 8f3e358 + 340d1a4 commit 43d9d39

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

docs/spec/v1alpha1/imageupdateautomations.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,24 @@ type ImageUpdateAutomationSpec struct {
2727
// value.
2828
// +kubebuilder:default={"strategy":"Setters"}
2929
Update *UpdateStrategy `json:"update,omitempty"`
30-
// Commit specifies how to commit to the git repo
30+
// Commit specifies how to commit to the git repository.
3131
// +required
3232
Commit CommitSpec `json:"commit"`
3333

34+
// Push specifies how and where to push commits made by the
35+
// automation. If missing, commits are pushed (back) to
36+
// `.spec.checkout.branch`.
37+
// +optional
38+
Push *PushSpec `json:"push,omitempty"`
39+
3440
// Suspend tells the controller to not run this automation, until
3541
// it is unset (or set to false). Defaults to false.
3642
// +optional
3743
Suspend bool `json:"suspend,omitempty"`
3844
}
3945
```
4046

41-
See the sections below, regarding `checkout`, `update`, and `commit`.
47+
See the sections below regarding `checkout`, `update`, `commit`, and `push`.
4248

4349
The required `interval` field gives a period for automation runs, in [duration notation][durations];
4450
e.g., `"5m"`.
@@ -67,8 +73,8 @@ with write access; e.g., if using a GitHub deploy key, "Allow write access" shou
6773
creating it. Only the `url`, `secretRef` and `gitImplementation` (see just below) fields of the
6874
`GitRepository` are used.
6975

70-
The `branch` field names the branch in the git repository to check out; this will also be the branch
71-
the controller pushes commits to.
76+
The `branch` field names the branch in the git repository to check out. When the `push` field is not
77+
present (see [below](#push)), this will also be the branch pushed back to the origin repository.
7278

7379
**Git implementation**
7480

@@ -256,6 +262,44 @@ spec:
256262
{{ end -}}
257263
```
258264

265+
## Push
266+
267+
The optional `push` field defines how commits are pushed to the origin.
268+
269+
```go
270+
// PushSpec specifies how and where to push commits.
271+
type PushSpec struct {
272+
// Branch specifies that commits should be pushed to the branch
273+
// named. The branch is created using `.spec.checkout.branch` as the
274+
// starting point, if it doesn't already exist.
275+
// +required
276+
Branch string `json:"branch"`
277+
}
278+
```
279+
280+
If `push` is not present, commits are made on the same branch as `.spec.checkout.branch` and pushed
281+
to the same branch at the origin.
282+
283+
When `push` is present, the `.spec.push.branch` field specifies a branch to push to at the
284+
origin. The branch will be created locally if it does not already exist, starting from
285+
`.spec.checkout.branch`. If it does already exist, updates will be calculated on top of any commits
286+
already on the branch.
287+
288+
In the following snippet, updates will be pushed as commits to the branch `auto`, and when that
289+
branch does not exist at the origin, it will be created locally starting from the branch `main` and
290+
pushed:
291+
292+
```yaml
293+
spec:
294+
# ... commit, update, etc.
295+
checkout:
296+
gitRepositoryRef:
297+
name: app-repo
298+
branch: main
299+
push:
300+
branch: auto
301+
```
302+
259303
## Status
260304
261305
The status of an `ImageUpdateAutomation` object records the result of the last automation run.

0 commit comments

Comments
 (0)