Skip to content

Commit c421bd2

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

File tree

6 files changed

+113
-84
lines changed

6 files changed

+113
-84
lines changed

.github/workflows/golangci-lint.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ 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
18+
cache-dependency-path: |
19+
**/go.sum
20+
**/go.mod
1921
- name: Download Flux manifests
2022
run: make manifests
2123
- name: Run tidy

.github/workflows/pre-commit.yaml

+1-3
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,8 +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
50+
go-version: 1.22.x
5351
cache-dependency-path: |
5452
**/go.sum
5553
**/go.mod

.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

+8-10
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ 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
22+
cache-dependency-path: |
23+
**/go.sum
24+
**/go.mod
2325
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
2426
with:
2527
terraform_version: "${{env.TERRAFORM_VERSION}}"
@@ -54,8 +56,7 @@ jobs:
5456
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
5557
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
5658
with:
57-
go-version-file: 'go.mod'
58-
cache: true
59+
go-version: 1.22.x
5960
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
6061
with:
6162
terraform_version: ${{ matrix.terraform }}
@@ -72,8 +73,7 @@ jobs:
7273
- name: Setup Go
7374
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
7475
with:
75-
go-version-file: 'go.mod'
76-
cache: true
76+
go-version: 1.22.x
7777
cache-dependency-path: |
7878
**/go.sum
7979
**/go.mod
@@ -155,8 +155,7 @@ jobs:
155155
- name: Setup Go
156156
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
157157
with:
158-
go-version-file: 'go.mod'
159-
cache: true
158+
go-version: 1.22.x
160159
cache-dependency-path: |
161160
**/go.sum
162161
**/go.mod
@@ -210,8 +209,7 @@ jobs:
210209
- name: Setup Go
211210
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
212211
with:
213-
go-version-file: 'go.mod'
214-
cache: true
212+
go-version: 1.22.x
215213
cache-dependency-path: |
216214
**/go.sum
217215
**/go.mod

.github/workflows/update-flux.yaml

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

.github/workflows/update.yaml

-67
This file was deleted.

0 commit comments

Comments
 (0)