Skip to content

Commit dfb08f3

Browse files
stefanprodanmatheuscscp
authored andcommitted
ci: Refactor CI with fluxcd/gha-workflows
Signed-off-by: Stefan Prodan <[email protected]>
1 parent 9617e0e commit dfb08f3

File tree

6 files changed

+51
-235
lines changed

6 files changed

+51
-235
lines changed

.github/workflows/backport.yaml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,12 @@
11
name: backport
2-
32
on:
43
pull_request_target:
54
types: [closed, labeled]
6-
75
jobs:
8-
pull-request:
9-
runs-on: ubuntu-latest
6+
backport:
107
permissions:
11-
contents: write
12-
pull-requests: write
13-
if: github.event.pull_request.state == 'closed' && github.event.pull_request.merged && (github.event_name != 'labeled' || startsWith('backport:', github.event.label.name))
14-
steps:
15-
- name: Checkout
16-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17-
with:
18-
ref: ${{ github.event.pull_request.head.sha }}
19-
- name: Create backport PRs
20-
uses: korthout/backport-action@ca4972adce8039ff995e618f5fc02d1b7961f27a # v3.3.0
21-
# xref: https://github.com/korthout/backport-action#inputs
22-
with:
23-
# Use token to allow workflows to be triggered for the created PR
24-
github_token: ${{ secrets.BOT_GITHUB_TOKEN }}
25-
# Match labels with a pattern `backport:<target-branch>`
26-
label_pattern: '^backport:([^ ]+)$'
27-
# A bit shorter pull-request title than the default
28-
pull_title: '[${target_branch}] ${pull_title}'
29-
# Simpler PR description than default
30-
pull_description: |-
31-
Automated backport to `${target_branch}`, triggered by a label in #${pull_number}.
8+
contents: write # for reading and creating branches.
9+
pull-requests: write # for creating pull requests against release branches.
10+
uses: fluxcd/gha-workflows/.github/workflows/[email protected]
11+
secrets:
12+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build.yaml

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,22 @@ on:
44
pull_request:
55
push:
66
branches: [ 'main', 'release/**' ]
7-
8-
permissions:
9-
contents: read # for actions/checkout to fetch code
10-
117
jobs:
128
test-linux-amd64:
139
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read # for reading the repository code.
1412
steps:
15-
- name: checkout
16-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17-
- name: Setup Go
18-
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
19-
with:
20-
go-version: 1.25.x
21-
cache-dependency-path: |
22-
**/go.sum
23-
**/go.mod
24-
- name: Setup QEMU
25-
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
26-
- name: Setup Docker Buildx
27-
id: buildx
28-
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
29-
- name: Run tests
30-
run: make test
31-
- name: Verify
32-
run: make verify
33-
- name: Build multi-arch container image
34-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
35-
with:
36-
push: false
37-
builder: ${{ steps.buildx.outputs.name }}
38-
context: .
39-
file: ./Dockerfile
40-
platforms: linux/amd64,linux/arm/v7,linux/arm64
41-
tags: |
42-
${{ github.repository }}:latest
13+
- name: Test suite setup
14+
uses: fluxcd/gha-workflows/.github/actions/[email protected]
15+
with:
16+
go-version: 1.25.x
17+
- name: Run tests
18+
run: make test
19+
- name: Verify
20+
run: make verify
21+
- name: Build container image
22+
run: |
23+
make docker-build IMG=ghcr.io/fluxcd/${{ github.event.repository.name }} \
24+
BUILD_PLATFORMS=linux/amd64 \
25+
BUILD_ARGS="--load"

.github/workflows/cifuzz.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,15 @@ name: fuzz
22
on:
33
pull_request:
44
branches: [ 'main', 'release/**' ]
5-
6-
permissions:
7-
contents: read # for actions/checkout to fetch code
8-
95
jobs:
106
smoketest:
117
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read # for reading the repository code.
1210
steps:
13-
- name: Checkout
14-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
15-
- name: Setup Go
16-
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
11+
- name: Test suite setup
12+
uses: fluxcd/gha-workflows/.github/actions/[email protected]
1713
with:
1814
go-version: 1.25.x
19-
cache-dependency-path: |
20-
**/go.sum
21-
**/go.mod
2215
- name: Smoke test Fuzzers
2316
run: make fuzz-smoketest

.github/workflows/release.yml

Lines changed: 10 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -7,115 +7,21 @@ on:
77
inputs:
88
tag:
99
description: 'image tag prefix'
10-
default: 'preview'
10+
default: 'rc'
1111
required: true
12-
13-
permissions:
14-
contents: read
15-
16-
env:
17-
CONTROLLER: ${{ github.event.repository.name }}
18-
1912
jobs:
2013
release:
21-
outputs:
22-
hashes: ${{ steps.slsa.outputs.hashes }}
23-
image_url: ${{ steps.slsa.outputs.image_url }}
24-
image_digest: ${{ steps.slsa.outputs.image_digest }}
25-
runs-on: ubuntu-latest
2614
permissions:
2715
contents: write # for creating the GitHub release.
2816
id-token: write # for creating OIDC tokens for signing.
2917
packages: write # for pushing and signing container images.
30-
steps:
31-
- name: Checkout
32-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
33-
- name: Setup Kustomize
34-
uses: fluxcd/pkg/actions/kustomize@main
35-
- name: Prepare
36-
id: prep
37-
run: |
38-
VERSION="${{ github.event.inputs.tag }}-${GITHUB_SHA::8}"
39-
if [[ $GITHUB_REF == refs/tags/* ]]; then
40-
VERSION=${GITHUB_REF/refs\/tags\//}
41-
fi
42-
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
43-
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
44-
- name: Setup QEMU
45-
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
46-
- name: Setup Docker Buildx
47-
id: buildx
48-
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
49-
- name: Login to GitHub Container Registry
50-
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
51-
with:
52-
registry: ghcr.io
53-
username: fluxcdbot
54-
password: ${{ secrets.GHCR_TOKEN }}
55-
- name: Login to Docker Hub
56-
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
57-
with:
58-
username: fluxcdbot
59-
password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
60-
- name: Generate images meta
61-
id: meta
62-
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
63-
with:
64-
images: |
65-
fluxcd/${{ env.CONTROLLER }}
66-
ghcr.io/fluxcd/${{ env.CONTROLLER }}
67-
tags: |
68-
type=raw,value=${{ steps.prep.outputs.VERSION }}
69-
- name: Publish images
70-
id: build-push
71-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
72-
with:
73-
sbom: true
74-
provenance: true
75-
push: true
76-
builder: ${{ steps.buildx.outputs.name }}
77-
context: .
78-
file: ./Dockerfile
79-
platforms: linux/amd64,linux/arm/v7,linux/arm64
80-
tags: ${{ steps.meta.outputs.tags }}
81-
labels: ${{ steps.meta.outputs.labels }}
82-
- uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
83-
- name: Sign images
84-
env:
85-
COSIGN_EXPERIMENTAL: 1
86-
run: |
87-
cosign sign --yes fluxcd/${{ env.CONTROLLER }}@${{ steps.build-push.outputs.digest }}
88-
cosign sign --yes ghcr.io/fluxcd/${{ env.CONTROLLER }}@${{ steps.build-push.outputs.digest }}
89-
- name: Generate release artifacts
90-
if: startsWith(github.ref, 'refs/tags/v')
91-
run: |
92-
mkdir -p config/release
93-
kustomize build ./config/crd > ./config/release/${{ env.CONTROLLER }}.crds.yaml
94-
kustomize build ./config/manager > ./config/release/${{ env.CONTROLLER }}.deployment.yaml
95-
- uses: anchore/sbom-action/download-syft@da167eac915b4e86f08b264dbdbc867b61be6f0c # v0.20.5
96-
- name: Create release and SBOM
97-
id: run-goreleaser
98-
if: startsWith(github.ref, 'refs/tags/v')
99-
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
100-
with:
101-
version: latest
102-
args: release --clean --skip=validate
103-
env:
104-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105-
- name: Generate SLSA metadata
106-
id: slsa
107-
env:
108-
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}"
109-
run: |
110-
hashes=$(echo -E $ARTIFACTS | jq --raw-output '.[] | {name, "digest": (.extra.Digest // .extra.Checksum)} | select(.digest) | {digest} + {name} | join(" ") | sub("^sha256:";"")' | base64 -w0)
111-
echo "hashes=$hashes" >> $GITHUB_OUTPUT
112-
113-
image_url=fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.version }}
114-
echo "image_url=$image_url" >> $GITHUB_OUTPUT
115-
116-
image_digest=${{ steps.build-push.outputs.digest }}
117-
echo "image_digest=$image_digest" >> $GITHUB_OUTPUT
118-
18+
uses: fluxcd/gha-workflows/.github/workflows/[email protected]
19+
with:
20+
controller: ${{ github.event.repository.name }}
21+
release-candidate-prefix: ${{ github.event.inputs.tag }}
22+
secrets:
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
dockerhub-token: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
11925
release-provenance:
12026
needs: [release]
12127
permissions:
@@ -128,10 +34,10 @@ jobs:
12834
provenance-name: "provenance.intoto.jsonl"
12935
base64-subjects: "${{ needs.release.outputs.hashes }}"
13036
upload-assets: true
131-
13237
dockerhub-provenance:
13338
needs: [release]
13439
permissions:
40+
contents: read # for reading the repository code.
13541
actions: read # for detecting the Github Actions environment.
13642
id-token: write # for creating OIDC tokens for signing.
13743
packages: write # for uploading attestations.
@@ -143,10 +49,10 @@ jobs:
14349
registry-username: fluxcdbot
14450
secrets:
14551
registry-password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
146-
14752
ghcr-provenance:
14853
needs: [release]
14954
permissions:
55+
contents: read # for reading the repository code.
15056
actions: read # for detecting the Github Actions environment.
15157
id-token: write # for creating OIDC tokens for signing.
15258
packages: write # for uploading attestations.

.github/workflows/scan.yml

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,17 @@
11
name: scan
2-
32
on:
43
push:
5-
branches: [ 'main', 'release/**' ]
4+
branches: [ main ]
65
pull_request:
7-
branches: [ 'main', 'release/**' ]
6+
branches: [ main ]
87
schedule:
98
- cron: '18 10 * * 3'
10-
11-
permissions:
12-
contents: read # for actions/checkout to fetch code
13-
security-events: write # for codeQL to write security events
14-
159
jobs:
16-
fossa:
17-
name: FOSSA
18-
runs-on: ubuntu-latest
19-
steps:
20-
- name: Checkout
21-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
22-
- name: Run FOSSA scan and upload build data
23-
uses: fossa-contrib/fossa-action@3d2ef181b1820d6dcd1972f86a767d18167fa19b # v3.0.1
24-
with:
25-
# FOSSA Push-Only API Token
26-
fossa-api-key: 5ee8bf422db1471e0bcf2bcb289185de
27-
github-token: ${{ github.token }}
28-
29-
codeql:
30-
name: CodeQL
31-
runs-on: ubuntu-latest
32-
steps:
33-
- name: Checkout
34-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
35-
- name: Setup Go
36-
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
37-
with:
38-
go-version: 1.25.x
39-
cache-dependency-path: |
40-
**/go.sum
41-
**/go.mod
42-
- name: Initialize CodeQL
43-
uses: github/codeql-action/init@3c3833e0f8c1c83d449a7478aa59c036a9165498 # v3.29.11
44-
with:
45-
languages: go
46-
# xref: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
47-
# xref: https://codeql.github.com/codeql-query-help/go/
48-
queries: security-and-quality
49-
- name: Autobuild
50-
uses: github/codeql-action/autobuild@3c3833e0f8c1c83d449a7478aa59c036a9165498 # v3.29.11
51-
- name: Perform CodeQL Analysis
52-
uses: github/codeql-action/analyze@3c3833e0f8c1c83d449a7478aa59c036a9165498 # v3.29.11
10+
analyze:
11+
permissions:
12+
contents: read # for reading the repository code.
13+
security-events: write # for uploading the CodeQL analysis results.
14+
uses: fluxcd/gha-workflows/.github/workflows/[email protected]
15+
secrets:
16+
github-token: ${{ secrets.GITHUB_TOKEN }}
17+
fossa-token: ${{ secrets.FOSSA_TOKEN }}

.github/workflows/sync-labels.yaml

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,11 @@ on:
66
- main
77
paths:
88
- .github/labels.yaml
9-
10-
permissions:
11-
contents: read
12-
139
jobs:
14-
labels:
15-
name: Run sync
16-
runs-on: ubuntu-latest
10+
sync-labels:
1711
permissions:
18-
issues: write
19-
steps:
20-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
21-
- uses: EndBug/label-sync@52074158190acb45f3077f9099fea818aa43f97a # v2.3.3
22-
with:
23-
# Configuration file
24-
config-file: |
25-
https://raw.githubusercontent.com/fluxcd/community/main/.github/standard-labels.yaml
26-
.github/labels.yaml
27-
# Strictly declarative
28-
delete-other-labels: true
12+
contents: read # for reading the labels file.
13+
issues: write # for creating and updating labels.
14+
uses: fluxcd/gha-workflows/.github/workflows/[email protected]
15+
secrets:
16+
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)