Skip to content

Commit f9d572a

Browse files
authored
Merge pull request #5 from fluxcd/setup-kubernetes
Add composite action for Kubernetes e2e testing
2 parents 6d93b36 + 24ca127 commit f9d572a

File tree

3 files changed

+91
-22
lines changed

3 files changed

+91
-22
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: setup-kubernetes
2+
author: "The Flux Authors"
3+
description: Setups Kubernetes Kind cluster and Docker BuildKit for Flux controller e2e testing
4+
inputs:
5+
go-version:
6+
description: 'Go version to setup'
7+
required: true
8+
kind-version:
9+
description: 'Kind version to setup'
10+
required: false
11+
default: 'v0.30.0'
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17+
- name: Setup Kustomize
18+
uses: fluxcd/pkg/actions/kustomize@bf02f0a2d612cc07e0892166369fa8f63246aabb # main
19+
- name: Setup QEMU
20+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
21+
- name: Setup Docker Buildx
22+
id: buildx
23+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
24+
- name: Setup Go
25+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
26+
with:
27+
go-version: ${{ inputs.go-version }}
28+
cache-dependency-path: |
29+
**/go.sum
30+
**/go.mod
31+
- name: Setup Kubernetes
32+
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0
33+
with:
34+
version: ${{ inputs.kind-version }}
35+
cluster_name: kind

.github/dependabot.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ version: 2
22

33
updates:
44
- package-ecosystem: "github-actions"
5-
directory: "/"
5+
directories:
6+
- "/"
7+
- "/.github/actions/*"
68
groups:
79
actions:
810
patterns:

README.md

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,35 @@
33
[![license](https://img.shields.io/github/license/fluxcd/gha-workflows.svg)](https://github.com/fluxcd/gha-workflows/blob/main/LICENSE)
44
[![release](https://img.shields.io/github/release/fluxcd/gha-workflows/all.svg)](https://github.com/fluxcd/gha-workflows/releases)
55

6-
This repository contains reusable GitHub Workflows shared across the Flux controller repositories.
6+
This repository contains reusable GitHub Workflows and Composite Actions shared across the Flux controller repositories.
77

88
## Workflows
99

10-
### Release Flux controllers
10+
### Release Flux controller
1111

1212
The [controller-release](.github/workflows/controller-release.yaml) workflow automates the release of
1313
Flux controllers by performing the following steps:
1414

15-
- Builds multi-arch images for `linux/amd64`, `linux/arm64` and `linux/arm/v7` with Docker
16-
- Generates SBOMs for each architecture with Syft
17-
- Pushes the images to `ghcr.io/fluxcd` and `docker.io/fluxcd`
18-
- Signs the images with Cosign and GitHub OIDC
19-
- Creates a GitHub Release with GoReleaser
20-
- Outputs metadata for SLSA attestations
15+
- Builds multi-arch images for `linux/amd64`, `linux/arm64` and `linux/arm/v7` with Docker.
16+
- Generates SBOMs for each architecture with Syft.
17+
- Pushes the images to `ghcr.io/fluxcd` and `docker.io/fluxcd`.
18+
- Signs the images with Cosign and GitHub OIDC.
19+
- Creates a GitHub Release with GoReleaser.
20+
- Outputs metadata for SLSA attestations.
2121

2222
Example usage:
2323

2424
```yaml
2525
name: release
26-
2726
on:
2827
push:
29-
tags:
30-
- 'v*'
28+
tags: [ 'v*' ]
3129
workflow_dispatch:
3230
inputs:
3331
tag:
3432
description: 'image tag prefix'
3533
default: 'rc'
3634
required: false
37-
3835
jobs:
3936
release:
4037
permissions:
@@ -47,7 +44,7 @@ jobs:
4744
release-candidate-prefix: ${{ github.event.inputs.tag }}
4845
secrets:
4946
github-token: ${{ secrets.GITHUB_TOKEN }}
50-
dockerhub-token: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
47+
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
5148
```
5249
5350
3rd-party actions used:
@@ -83,8 +80,8 @@ on:
8380
jobs:
8481
backport:
8582
permissions:
86-
contents: write
87-
pull-requests: write
83+
contents: write # for reading and creating branches.
84+
pull-requests: write # for creating pull requests against release branches.
8885
uses: fluxcd/gha-workflows/.github/workflows/[email protected]
8986
secrets:
9087
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -112,8 +109,8 @@ on:
112109
jobs:
113110
analyze:
114111
permissions:
115-
contents: read
116-
security-events: write
112+
contents: read # for reading the repository code.
113+
security-events: write # for uploading the CodeQL analysis results.
117114
uses: fluxcd/gha-workflows/.github/workflows/[email protected]
118115
secrets:
119116
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -140,15 +137,14 @@ name: sync-labels
140137
on:
141138
workflow_dispatch:
142139
push:
143-
branches:
144-
- main
140+
branches: [ main ]
145141
paths:
146142
- .github/labels.yaml
147143
jobs:
148144
sync-labels:
149145
permissions:
150-
issues: write
151-
contents: read
146+
contents: read # for reading the labels file.
147+
issues: write # for creating and updating labels.
152148
uses: fluxcd/gha-workflows/.github/workflows/[email protected]
153149
with:
154150
labels-file: .github/labels.yaml
@@ -160,6 +156,42 @@ jobs:
160156

161157
- [EndBug/label-sync](https://github.com/EndBug/label-sync)
162158

159+
## Composite Actions
160+
161+
### Setup Kubernetes
162+
163+
The [setup-kubernetes](.github/actions/setup-kubernetes/action.yaml) composite action configures
164+
the GitHub runner to build and test Flux controllers with Kubernetes Kind clusters.
165+
166+
Example usage:
167+
168+
```yaml
169+
name: e2e
170+
on:
171+
pull_request:
172+
push:
173+
branches: [ main ]
174+
jobs:
175+
kind:
176+
runs-on: ubuntu-latest
177+
permissions:
178+
contents: read # for reading the repository code.
179+
steps:
180+
- name: Test suite setup
181+
uses: fluxcd/gha-workflows/.github/actions/[email protected]
182+
with:
183+
go-version: 1.25.x
184+
kind-version: v0.30.0
185+
- name: Run tests
186+
run: make test
187+
```
188+
189+
3rd-party actions used:
190+
191+
- [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action)
192+
- [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action)
193+
- [helm/kind-action](https://github.com/helm/kind-action)
194+
163195
## Contributing
164196

165197
- The workflows must be placed in the `.github/workflows` directory and

0 commit comments

Comments
 (0)