Skip to content

Commit b40ea98

Browse files
committed
Updating flux update GH action to regen docs.
Signed-off-by: Steven Wade <[email protected]>
1 parent f88c0c6 commit b40ea98

File tree

6 files changed

+104
-96
lines changed

6 files changed

+104
-96
lines changed

.github/workflows/golangci-lint.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ jobs:
1414
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
1515
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
1616
with:
17-
go-version-file: 'go.mod'
18-
cache: true
17+
go-version: 1.22.x
1918
- name: Download Flux manifests
2019
run: make manifests
2120
- name: Run tidy

.github/workflows/pre-commit.yaml

+1-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jobs:
2323
steps:
2424
- name: Checkout
2525
uses: actions/checkout@v4
26-
2726
- name: Get root directories
2827
id: dirs
2928
uses: clowdhaus/terraform-composite-actions/[email protected]
@@ -48,11 +47,7 @@ jobs:
4847
- name: Setup Go
4948
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
5049
with:
51-
go-version-file: 'go.mod'
52-
cache: true
53-
cache-dependency-path: |
54-
**/go.sum
55-
**/go.mod
50+
go-version: 1.22.x
5651
- name: Build provider
5752
run: |
5853
make build

.github/workflows/release.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222
- name: Setup Go
2323
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
2424
with:
25-
go-version-file: 'go.mod'
26-
cache: true
25+
go-version: 1.22.x
26+
cache: false
2727
- name: Import GPG key
2828
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
2929
id: import_gpg

.github/workflows/tests.yaml

+5-19
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ jobs:
1818
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
1919
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
2020
with:
21-
go-version-file: 'go.mod'
22-
cache: true
21+
go-version: 1.22.x
2322
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
2423
with:
2524
terraform_version: "${{env.TERRAFORM_VERSION}}"
@@ -54,8 +53,7 @@ jobs:
5453
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
5554
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
5655
with:
57-
go-version-file: 'go.mod'
58-
cache: true
56+
go-version: 1.22.x
5957
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
6058
with:
6159
terraform_version: ${{ matrix.terraform }}
@@ -72,11 +70,7 @@ jobs:
7270
- name: Setup Go
7371
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
7472
with:
75-
go-version-file: 'go.mod'
76-
cache: true
77-
cache-dependency-path: |
78-
**/go.sum
79-
**/go.mod
73+
go-version: 1.22.x
8074
- name: Setup Flux CLI
8175
uses: fluxcd/flux2/action@534684601ec8888beb0cc4f51117b59e97606c4d # v2.2.3
8276
- name: Set outputs
@@ -155,11 +149,7 @@ jobs:
155149
- name: Setup Go
156150
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
157151
with:
158-
go-version-file: 'go.mod'
159-
cache: true
160-
cache-dependency-path: |
161-
**/go.sum
162-
**/go.mod
152+
go-version: 1.22.x
163153
- name: Setup Flux CLI
164154
uses: fluxcd/flux2/action@534684601ec8888beb0cc4f51117b59e97606c4d # v2.2.3
165155
- name: Set outputs
@@ -210,11 +200,7 @@ jobs:
210200
- name: Setup Go
211201
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
212202
with:
213-
go-version-file: 'go.mod'
214-
cache: true
215-
cache-dependency-path: |
216-
**/go.sum
217-
**/go.mod
203+
go-version: 1.22.x
218204
- name: Setup Flux CLI
219205
uses: fluxcd/flux2/action@534684601ec8888beb0cc4f51117b59e97606c4d # v2.2.3
220206
- name: Set outputs

.github/workflows/update-flux.yaml

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: update-flux
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 * * * *"
7+
8+
jobs:
9+
update-flux:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
14+
- name: Setup Go
15+
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
16+
with:
17+
go-version: 1.22.x
18+
- name: Setup Flux CLI
19+
uses: fluxcd/flux2/action@main
20+
with:
21+
token: ${{ secrets.GITHUB_TOKEN }}
22+
- name: Update component versions
23+
id: update
24+
run: |
25+
26+
latest_release=$(flux version --client | awk '{print $2}')
27+
28+
# Check if the tag was fetched successfully
29+
if [ "$latest_release" == "null" ] || [ -z "$latest_release" ]; then
30+
printf "Failed to fetch the latest release.\n"
31+
exit 1
32+
else
33+
printf "The latest release of Flux2 is: %s.\n" "${latest_release}"
34+
fi
35+
36+
# Obtain the current version of Flux2 leveraged in this repository
37+
# shellcheck disable=SC2046
38+
current_version=$(grep 'DefaultFluxVersion' internal/utils/flux.go | awk '{ print $5 }' | tr -d '"')
39+
printf "The current version of Flux2 in this repository is: %s.\n" "$current_version"
40+
41+
# If the latest release and the current version are the same, exit
42+
if [ "${latest_release}" == "${current_version}" ]; then
43+
printf "The current version of Flux2 in this repository is up to date. Exiting....\n"
44+
exit 0
45+
fi
46+
47+
# Replace the current version with the latest release
48+
sed -i "s/${current_version}/${latest_release}/g" internal/utils/flux.go
49+
printf "The version of Flux2 has been updated to %s.\n" "${latest_release}"
50+
51+
# Run go mod tidy to update the go.mod file
52+
go mod edit -require github.com/fluxcd/flux2/v2@"${latest_release}"
53+
go mod tidy -compat=1.22
54+
55+
# Run the build and generate the documentation
56+
printf "Running the build and generating the documentation...\n"
57+
make build
58+
make docs
59+
60+
git diff
61+
62+
PR_TITLE="Update Flux to ${latest_release}"
63+
PR_BODY=$(mktemp)
64+
echo "- github.com/fluxcd/flux2 to ${latest_release}" >> $PR_BODY
65+
echo " https://github.com/fluxcd/flux2/releases/${latest_release}" >> $PR_BODY
66+
67+
# NB: this may look strange but it is the way it should be done to
68+
# maintain our precious newlines
69+
# Ref: https://github.com/github/docs/issues/21529
70+
echo 'pr_body<<EOF' >> $GITHUB_OUTPUT
71+
cat $PR_BODY >> $GITHUB_OUTPUT
72+
echo 'EOF' >> $GITHUB_OUTPUT
73+
echo "pr_title=$PR_TITLE" >> $GITHUB_OUTPUT
74+
- name: Create Pull Request
75+
id: cpr
76+
uses: peter-evans/create-pull-request@9153d834b60caba6d51c9b9510b087acf9f33f83 # v6.0.4
77+
with:
78+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
79+
commit-message: |
80+
${{ steps.update.outputs.pr_title }}
81+
82+
${{ steps.update.outputs.pr_body }}
83+
committer: GitHub <[email protected]>
84+
author: fluxcdbot <[email protected]>
85+
signoff: true
86+
title: ${{ steps.update.outputs.pr_title }}
87+
body: |
88+
${{ steps.update.outputs.pr_body }}
89+
branch: update-components
90+
labels: |
91+
area/build
92+
reviewers: ${{ secrets.ASSIGNEES }}
93+
- name: Check output
94+
run: |
95+
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"

.github/workflows/update.yaml

-67
This file was deleted.

0 commit comments

Comments
 (0)