Skip to content

Commit 49d6e37

Browse files
authored
CI: Auto update Headlamp image (#20372)
Signed-off-by: Joaquim Rocha <[email protected]>
1 parent 8c6446f commit 49d6e37

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "update-headlamp-version"
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
# every Monday at around 3 am pacific/10 am UTC
6+
- cron: "0 10 * * 1"
7+
env:
8+
GOPROXY: https://proxy.golang.org
9+
GO_VERSION: '1.23.4'
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
bump-headlamp-version:
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
18+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
19+
with:
20+
go-version: ${{env.GO_VERSION}}
21+
- name: Bump Headlamp version
22+
id: bumpHeadlamp
23+
run: |
24+
echo "OLD_VERSION=$(DEP=headlamp make get-dependency-version)" >> "$GITHUB_OUTPUT"
25+
make update-headlamp-version
26+
echo "NEW_VERSION=$(DEP=headlamp make get-dependency-version)" >> "$GITHUB_OUTPUT"
27+
# The following is to support multiline with GITHUB_OUTPUT, see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
28+
echo "changes<<EOF" >> "$GITHUB_OUTPUT"
29+
echo "$(git status --porcelain)" >> "$GITHUB_OUTPUT"
30+
echo "EOF" >> "$GITHUB_OUTPUT"
31+
- name: Create PR
32+
if: ${{ steps.bumpHeadlamp.outputs.changes != '' }}
33+
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f
34+
with:
35+
token: ${{ secrets.MINIKUBE_BOT_PAT }}
36+
commit-message: 'Addon Headlamp: Update Headlamp image from ${{ steps.bumpHeadlamp.outputs.OLD_VERSION }} to ${{ steps.bumpHeadlamp.outputs.NEW_VERSION }}'
37+
committer: minikube-bot <[email protected]>
38+
author: minikube-bot <[email protected]>
39+
branch: auto_bump_headlamp_version
40+
push-to-fork: minikube-bot/minikube
41+
base: master
42+
delete-branch: true
43+
title: 'Addon Headlamp: Update Headlamp image from ${{ steps.bumpHeadlamp.outputs.OLD_VERSION }} to ${{ steps.bumpHeadlamp.outputs.NEW_VERSION }}'
44+
labels: ok-to-test
45+
body: |
46+
The [Headlamp](https://github.com/headlamp-k8s/headlamp) project released a new Headlamp image
47+
48+
This PR was auto-generated by `make update-headlamp-version` using [update-headlamp-version.yml](https://github.com/kubernetes/minikube/tree/master/.github/workflows/update-headlamp-version.yml) CI Workflow.

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,11 @@ update-kube-registry-proxy-version:
12721272
(cd hack/update/kube_registry_proxy_version && \
12731273
go run update_kube_registry_proxy_version.go)
12741274

1275+
.PHONY: update-headlamp-version
1276+
update-headlamp-version:
1277+
(cd hack/update/headlamp_version && \
1278+
go run update_headlamp_version.go)
1279+
12751280
.PHONY: get-dependency-verison
12761281
get-dependency-version:
12771282
@(cd hack/update/get_version && \
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
Copyright 2023 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"context"
21+
"fmt"
22+
"time"
23+
24+
"k8s.io/klog/v2"
25+
"k8s.io/minikube/hack/update"
26+
)
27+
28+
var schema = map[string]update.Item{
29+
"pkg/minikube/assets/addons.go": {
30+
Replace: map[string]string{
31+
`headlamp-k8s/headlamp:.*`: `headlamp-k8s/headlamp:{{.Version}}@{{.SHA}}",`,
32+
},
33+
},
34+
}
35+
36+
type Data struct {
37+
Version string
38+
SHA string
39+
}
40+
41+
func main() {
42+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
43+
defer cancel()
44+
45+
stable, _, _, err := update.GHReleases(ctx, "headlamp-k8s", "headlamp")
46+
if err != nil {
47+
klog.Fatalf("Unable to get stable version: %v", err)
48+
}
49+
sha, err := update.GetImageSHA(fmt.Sprintf("ghcr.io/headlamp-k8s/headlamp:%s", stable.Tag))
50+
if err != nil {
51+
klog.Fatalf("failed to get image SHA: %v", err)
52+
}
53+
54+
data := Data{Version: stable.Tag, SHA: sha}
55+
56+
update.Apply(schema, data)
57+
}

0 commit comments

Comments
 (0)