Skip to content

Commit 63fa38e

Browse files
authored
Merge pull request #271 from fluxcd/ci-gha-workflows
ci: Refactor CI with `fluxcd/gha-workflows`
2 parents e7971c6 + cf204a2 commit 63fa38e

File tree

5 files changed

+28
-142
lines changed

5 files changed

+28
-142
lines changed

.github/workflows/backport.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
jobs:
66
backport:
77
permissions:
8-
contents: write
9-
pull-requests: write
10-
uses: fluxcd/gha-workflows/.github/workflows/backport.yaml@v0.0.4
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/backport.yaml@v0.3.0
1111
secrets:
1212
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/code-scan.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ on:
77
jobs:
88
analyze:
99
permissions:
10-
contents: read
11-
security-events: write
12-
uses: fluxcd/gha-workflows/.github/workflows/code-scan.yaml@v0.0.4
10+
contents: read # for reading the repository code.
11+
security-events: write # for uploading the CodeQL analysis results.
12+
uses: fluxcd/gha-workflows/.github/workflows/code-scan.yaml@v0.3.0
1313
secrets:
1414
github-token: ${{ secrets.GITHUB_TOKEN }}
1515
fossa-token: ${{ secrets.FOSSA_TOKEN }}

.github/workflows/e2e.yaml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,19 @@
11
name: e2e
2-
32
on:
43
pull_request:
54
push:
65
branches:
76
- main
8-
97
jobs:
108
kind:
119
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read # for reading the repository code.
1212
steps:
13-
- name: Checkout
14-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
15-
- name: Setup QEMU
16-
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
17-
- name: Setup Docker Buildx
18-
id: buildx
19-
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
20-
- name: Setup Go
21-
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
13+
- name: Test suite setup
14+
uses: fluxcd/gha-workflows/.github/actions/[email protected]
2215
with:
2316
go-version: 1.25.x
24-
cache-dependency-path: |
25-
**/go.sum
26-
**/go.mod
27-
- name: Setup Kubernetes
28-
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0
29-
with:
30-
version: v0.30.0
31-
cluster_name: kind
32-
- name: Setup Kustomize
33-
uses: fluxcd/pkg/actions/kustomize@main
3417
- name: Run tests
3518
run: make test
3619
- name: Check if working tree is dirty

.github/workflows/labels-sync.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
jobs:
1010
sync-labels:
1111
permissions:
12-
issues: write
13-
contents: read
14-
uses: fluxcd/gha-workflows/.github/workflows/[email protected]
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 }}

.github/workflows/release.yaml

Lines changed: 13 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: release
2-
32
on:
43
push:
54
tags:
@@ -10,117 +9,19 @@ on:
109
description: 'image tag prefix'
1110
default: 'rc'
1211
required: true
13-
14-
permissions:
15-
contents: read
16-
17-
env:
18-
CONTROLLER: ${{ github.event.repository.name }}
19-
2012
jobs:
2113
release:
22-
outputs:
23-
hashes: ${{ steps.hash.outputs.hashes }}
24-
image_url: ${{ steps.hash.outputs.image_url }}
25-
image_digest: ${{ steps.hash.outputs.image_digest }}
26-
runs-on: ubuntu-latest
2714
permissions:
28-
contents: write # needed to write releases
29-
id-token: write # needed for keyless signing
30-
packages: write # needed for ghcr access
31-
steps:
32-
- name: Checkout
33-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
34-
- name: Setup Kustomize
35-
uses: fluxcd/pkg/actions/kustomize@main
36-
- name: Prepare
37-
id: prep
38-
run: |
39-
VERSION="${{ github.event.inputs.tag }}-${GITHUB_SHA::8}"
40-
if [[ $GITHUB_REF == refs/tags/* ]]; then
41-
VERSION=${GITHUB_REF/refs\/tags\//}
42-
fi
43-
echo "version=${VERSION}" >> $GITHUB_OUTPUT
44-
- name: Setup Go
45-
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
46-
with:
47-
go-version: 1.25.x
48-
cache-dependency-path: |
49-
**/go.sum
50-
**/go.mod
51-
- uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
52-
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
53-
- uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
54-
- uses: anchore/sbom-action/download-syft@da167eac915b4e86f08b264dbdbc867b61be6f0c # v0.20.5
55-
- name: Docker login ghcr.io
56-
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
57-
with:
58-
registry: ghcr.io
59-
username: fluxcdbot
60-
password: ${{ secrets.GHCR_TOKEN }}
61-
- name: Docker login docker.io
62-
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
63-
with:
64-
username: fluxcdbot
65-
password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
66-
- name: Docker meta
67-
id: meta
68-
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
69-
with:
70-
images: |
71-
fluxcd/${{ env.CONTROLLER }}
72-
ghcr.io/fluxcd/${{ env.CONTROLLER }}
73-
tags: |
74-
type=raw,value=${{ steps.prep.outputs.version }}
75-
- name: Docker push
76-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
77-
id: build-push
78-
with:
79-
sbom: true
80-
provenance: true
81-
push: true
82-
builder: ${{ steps.buildx.outputs.name }}
83-
context: .
84-
file: ./Dockerfile
85-
platforms: linux/amd64,linux/arm/v7,linux/arm64
86-
tags: ${{ steps.meta.outputs.tags }}
87-
labels: ${{ steps.meta.outputs.labels }}
88-
- name: Sign images
89-
env:
90-
COSIGN_EXPERIMENTAL: 1
91-
run: |
92-
cosign sign --yes fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.version }}
93-
cosign sign --yes ghcr.io/fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.version }}
94-
- name: Generate release artifacts
95-
if: startsWith(github.ref, 'refs/tags/v')
96-
run: |
97-
mkdir -p config/release
98-
kustomize build ./config/crd > ./config/release/${{ env.CONTROLLER }}.crds.yaml
99-
kustomize build ./config/manager > ./config/release/${{ env.CONTROLLER }}.deployment.yaml
100-
- name: GoReleaser publish signed SBOM
101-
id: run-goreleaser
102-
if: startsWith(github.ref, 'refs/tags/v')
103-
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
104-
with:
105-
version: latest
106-
args: release --clean --skip=validate
107-
env:
108-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109-
- name: Generate SLSA hashes
110-
id: hash
111-
env:
112-
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}"
113-
run: |
114-
set -euo pipefail
115-
116-
hashes=$(echo $ARTIFACTS | jq --raw-output '.[] | {name, "digest": (.extra.Digest // .extra.Checksum)} | select(.digest) | {digest} + {name} | join(" ") | sub("^sha256:";"")' | base64 -w0)
117-
echo "hashes=$hashes" >> $GITHUB_OUTPUT
118-
119-
image_url=fluxcd/${{ env.CONTROLLER }}:${{ steps.prep.outputs.version }}
120-
image_digest=${{ steps.build-push.outputs.digest }}
121-
echo "image_url=$image_url" >> $GITHUB_OUTPUT
122-
echo "image_digest=$image_digest" >> $GITHUB_OUTPUT
123-
15+
contents: write # for creating the GitHub release.
16+
id-token: write # for creating OIDC tokens for signing.
17+
packages: write # for pushing and signing container images.
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 }}
12425
release-provenance:
12526
needs: [release]
12627
permissions:
@@ -132,10 +33,10 @@ jobs:
13233
provenance-name: "provenance.intoto.jsonl"
13334
base64-subjects: "${{ needs.release.outputs.hashes }}"
13435
upload-assets: true
135-
13636
dockerhub-provenance:
13737
needs: [release]
13838
permissions:
39+
contents: read # for reading the repository code.
13940
actions: read # for detecting the Github Actions environment.
14041
id-token: write # for creating OIDC tokens for signing.
14142
packages: write # for uploading attestations.
@@ -146,10 +47,10 @@ jobs:
14647
registry-username: fluxcdbot
14748
secrets:
14849
registry-password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
149-
15050
ghcr-provenance:
15151
needs: [release]
15252
permissions:
53+
contents: read # for reading the repository code.
15354
actions: read # for detecting the Github Actions environment.
15455
id-token: write # for creating OIDC tokens for signing.
15556
packages: write # for uploading attestations.
@@ -159,4 +60,4 @@ jobs:
15960
digest: ${{ needs.release.outputs.image_digest }}
16061
registry-username: fluxcdbot
16162
secrets:
162-
registry-password: ${{ secrets.GHCR_TOKEN }}
63+
registry-password: ${{ secrets.GHCR_TOKEN }}

0 commit comments

Comments
 (0)