forked from weaveworks/weave-gitops
-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (53 loc) · 2 KB
/
upgrade-flux.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.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.