Skip to content

Commit

Permalink
CI: Auto update yakd addon image
Browse files Browse the repository at this point in the history
  • Loading branch information
spowelljr authored and medyagh committed Jun 27, 2024
1 parent bc331c8 commit 5ae6b21
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/update-yakd-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "update-yakd-version"
on:
workflow_dispatch:
schedule:
# every Monday at around 3 am pacific/10 am UTC
- cron: "0 10 * * 1"
env:
GOPROXY: https://proxy.golang.org
GO_VERSION: '1.22.4'
permissions:
contents: read

jobs:
bump-yakd-version:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
with:
go-version: ${{env.GO_VERSION}}
- name: Bump yakd version
id: bumpYakd
run: |
echo "OLD_VERSION=$(DEP=yakd make get-dependency-version)" >> "$GITHUB_OUTPUT"
make update-yakd-version
echo "NEW_VERSION=$(DEP=yakd make get-dependency-version)" >> "$GITHUB_OUTPUT"
# 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
echo "changes<<EOF" >> "$GITHUB_OUTPUT"
echo "$(git status --porcelain)" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Create PR
if: ${{ steps.bumpYakd.outputs.changes != '' }}
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c
with:
token: ${{ secrets.MINIKUBE_BOT_PAT }}
commit-message: 'Addon yakd: Update marcnuri/yakd image from ${{ steps.bumpYakd.outputs.OLD_VERSION }} to ${{ steps.bumpYakd.outputs.NEW_VERSION }}'
committer: minikube-bot <minikube-bot@google.com>
author: minikube-bot <minikube-bot@google.com>
branch: auto_bump_yakd_version
push-to-fork: minikube-bot/minikube
base: master
delete-branch: true
title: 'Addon yakd: Update marcnuri/yakd image from ${{ steps.bumpYakd.outputs.OLD_VERSION }} to ${{ steps.bumpYakd.outputs.NEW_VERSION }}'
labels: ok-to-test
body: |
The [yakd](https://github.com/manusa/yakd) project released a new yakd image
This PR was auto-generated by `make update-yakd-version` using [update-yakd-version.yml](https://github.com/kubernetes/minikube/tree/master/.github/workflows/update-yakd-version.yml) CI Workflow.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,11 @@ update-cilium-version:
(cd hack/update/cilium_version && \
go run update_cilium_version.go)

.PHONY: update-yakd-version
update-yakd-version:
(cd hack/update/yakd_version && \
go run update_yakd_version.go)

.PHONY: get-dependency-verison
get-dependency-version:
@(cd hack/update/get_version && \
Expand Down
1 change: 1 addition & 0 deletions hack/update/get_version/get_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var dependencies = map[string]dependency{
"registry": {addonsFile, `registry:(.*)@`},
"runc": {"deploy/iso/minikube-iso/package/runc-master/runc-master.mk", `RUNC_MASTER_VERSION = (.*)`},
"ubuntu": {dockerfile, `ubuntu:jammy-(.*)"`},
"yakd": {addonsFile, `marcnuri/yakd:(.*)@`},
}

func main() {
Expand Down
59 changes: 59 additions & 0 deletions hack/update/yakd_version/update_yakd_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright 2024 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"context"
"fmt"
"strings"
"time"

"k8s.io/klog/v2"
"k8s.io/minikube/hack/update"
)

var schema = map[string]update.Item{
"pkg/minikube/assets/addons.go": {
Replace: map[string]string{
`marcnuri/yakd:.*`: `marcnuri/yakd:{{.Version}}@{{.SHA}}",`,
},
},
}

type Data struct {
Version string
SHA string
}

func main() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()

stable, _, _, err := update.GHReleases(ctx, "manusa", "yakd")
if err != nil {
klog.Fatalf("Unable to get stable version: %v", err)
}
version := strings.TrimPrefix(stable.Tag, "v")
sha, err := update.GetImageSHA(fmt.Sprintf("docker.io/marcnuri/yakd:%s", version))
if err != nil {
klog.Fatalf("failed to get image SHA: %v", err)
}

data := Data{Version: version, SHA: sha}

update.Apply(schema, data)
}

0 comments on commit 5ae6b21

Please sign in to comment.