Skip to content

Commit

Permalink
Merge pull request #671 from swade1987/bump-flux
Browse files Browse the repository at this point in the history
Updating flux update GH action to regen docs.
  • Loading branch information
stefanprodan authored Apr 24, 2024
2 parents f88c0c6 + c421bd2 commit 192ca62
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 84 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
go-version: 1.22.x
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Download Flux manifests
run: make manifests
- name: Run tidy
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get root directories
id: dirs
uses: clowdhaus/terraform-composite-actions/[email protected]
Expand All @@ -48,8 +47,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
go-version: 1.22.x
cache-dependency-path: |
**/go.sum
**/go.mod
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
go-version: 1.22.x
cache: false
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
id: import_gpg
Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
go-version: 1.22.x
cache-dependency-path: |
**/go.sum
**/go.mod
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
with:
terraform_version: "${{env.TERRAFORM_VERSION}}"
Expand Down Expand Up @@ -54,8 +56,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
go-version: 1.22.x
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
with:
terraform_version: ${{ matrix.terraform }}
Expand All @@ -72,8 +73,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
go-version: 1.22.x
cache-dependency-path: |
**/go.sum
**/go.mod
Expand Down Expand Up @@ -155,8 +155,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
go-version: 1.22.x
cache-dependency-path: |
**/go.sum
**/go.mod
Expand Down Expand Up @@ -210,8 +209,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
go-version: 1.22.x
cache-dependency-path: |
**/go.sum
**/go.mod
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/update-flux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: update-flux

on:
workflow_dispatch:
schedule:
- cron: "0 * * * *"

jobs:
update-flux:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.22.x
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Setup Flux CLI
uses: fluxcd/flux2/action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update component versions
id: update
run: |
latest_release=$(flux version --client | awk '{print $2}')
# Check if the tag was fetched successfully
if [ "$latest_release" == "null" ] || [ -z "$latest_release" ]; then
printf "Failed to fetch the latest release.\n"
exit 1
else
printf "The latest release of Flux2 is: %s.\n" "${latest_release}"
fi
# Obtain the current version of Flux2 leveraged in this repository
# shellcheck disable=SC2046
current_version=$(grep 'DefaultFluxVersion' internal/utils/flux.go | awk '{ print $5 }' | tr -d '"')
printf "The current version of Flux2 in this repository is: %s.\n" "$current_version"
# If the latest release and the current version are the same, exit
if [ "${latest_release}" == "${current_version}" ]; then
printf "The current version of Flux2 in this repository is up to date. Exiting....\n"
exit 0
fi
# Replace the current version with the latest release
sed -i "s/${current_version}/${latest_release}/g" internal/utils/flux.go
printf "The version of Flux2 has been updated to %s.\n" "${latest_release}"
# Run go mod tidy to update the go.mod file
go mod edit -require github.com/fluxcd/flux2/v2@"${latest_release}"
go mod tidy -compat=1.22
# Run the build and generate the documentation
printf "Running the build and generating the documentation...\n"
make build
make docs
git diff
PR_TITLE="Update Flux to ${latest_release}"
PR_BODY=$(mktemp)
echo "- github.com/fluxcd/flux2 to ${latest_release}" >> $PR_BODY
echo " https:/fluxcd/flux2/releases/${latest_release}" >> $PR_BODY
# NB: this may look strange but it is the way it should be done to
# maintain our precious newlines
# Ref: https:/github/docs/issues/21529
echo 'pr_body<<EOF' >> $GITHUB_OUTPUT
cat $PR_BODY >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
echo "pr_title=$PR_TITLE" >> $GITHUB_OUTPUT
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@9153d834b60caba6d51c9b9510b087acf9f33f83 # v6.0.4
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
commit-message: |
${{ steps.update.outputs.pr_title }}
${{ steps.update.outputs.pr_body }}
committer: GitHub <[email protected]>
author: fluxcdbot <[email protected]>
signoff: true
title: ${{ steps.update.outputs.pr_title }}
body: |
${{ steps.update.outputs.pr_body }}
branch: update-components
labels: |
area/build
reviewers: ${{ secrets.ASSIGNEES }}
- name: Check output
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
67 changes: 0 additions & 67 deletions .github/workflows/update.yaml

This file was deleted.

0 comments on commit 192ca62

Please sign in to comment.