Skip to content

Upgrade flux

Upgrade flux #11

Workflow file for this run

name: Upgrade flux
on:
workflow_dispatch:
schedule:
- cron: "0 10 * * *"
permissions:
contents: read # for actions/checkout to fetch code
jobs:
has-new-flux:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set new version if different
id: version
run: |
old_version="$(grep '^FLUX_VERSION=' Makefile | cut -d'=' -f2)"
new_version="$(curl -s --request GET --url "https://api.github.com/repos/fluxcd/flux2/releases?per_page=1" | jq . | jq '.[0] | .tag_name' | jq -r | sed -e 's/v//')"
if [[ "$old_version" != "$new_version" ]]; then
echo "version=$new_version" >> $GITHUB_OUTPUT
fi
upgrade-flux:
needs:
- has-new-flux
runs-on: ubuntu-latest
if: needs.has-new-flux.outputs.version
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version-file: go.mod
- name: Upgrade flux
run: |
sed -i 's/^FLUX_VERSION=.*/FLUX_VERSION=${{ needs.has-new-flux.outputs.version }}/' Makefile
go get -u github.com/fluxcd/flux2
go mod tidy
- name: Create Pull Request
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6
with:
author: weave-gitops-bot <[email protected]>
signoff: true
committer: weave-gitops-bot <[email protected]>
branch: upgrade-flux
base: main
title: "Upgrade flux to ${{ needs.has-new-flux.outputs.version }}"
token: ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }}
body: |
Upgrade the flux version used by gitops run and the package
dependencies.