Skip to content

Commit

Permalink
Updating flux update GH action to regen docs.
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Wade <steven@stevenwade.co.uk>
  • Loading branch information
swade1987 committed Apr 24, 2024
1 parent f88c0c6 commit 259b8f4
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 102 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
- name: Download Flux manifests
run: make manifests
- name: Run tidy
Expand Down
7 changes: 0 additions & 7 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/directories@v1.9.0
Expand All @@ -47,12 +46,6 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Build provider
run: |
make build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
cache: false
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
id: import_gpg
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
with:
terraform_version: "${{env.TERRAFORM_VERSION}}"
Expand Down Expand Up @@ -53,9 +50,6 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
with:
terraform_version: ${{ matrix.terraform }}
Expand All @@ -71,12 +65,6 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Setup Flux CLI
uses: fluxcd/flux2/action@534684601ec8888beb0cc4f51117b59e97606c4d # v2.2.3
- name: Set outputs
Expand Down Expand Up @@ -154,12 +142,6 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Setup Flux CLI
uses: fluxcd/flux2/action@534684601ec8888beb0cc4f51117b59e97606c4d # v2.2.3
- name: Set outputs
Expand Down Expand Up @@ -209,12 +191,6 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version-file: 'go.mod'
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Setup Flux CLI
uses: fluxcd/flux2/action@534684601ec8888beb0cc4f51117b59e97606c4d # v2.2.3
- name: Set outputs
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/update-flux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
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
- 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.20
# 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://github.com/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.com/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 <noreply@github.com>
author: fluxcdbot <fluxcdbot@users.noreply.github.com>
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 259b8f4

Please sign in to comment.