Skip to content

PR to update minikube #52

PR to update minikube

PR to update minikube #52

name: PR to update minikube
# This action will run after the "Publish container" is succesfully completed
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
on:
workflow_run:
workflows: ["Publish container"]
types:
- completed
workflow_dispatch:
env:
LATEST_HEADLAMP_TAG: latest
jobs:
create_pr_to_upgrade_minikube:
name: Create PR to upgrade minikube
runs-on: ubuntu-latest
steps:
- name: Checkout headlamp repo
uses: actions/checkout@v4
with:
path: headlamp
fetch-depth: 0
- name: Configure Git
run: |
user=${{github.actor}}
if [ -z $user ]; then
user=yolossn
fi
git config --global user.name "$user"
git config --global user.email "[email protected]"
- name: Get headlamp latest tag
run: |
cd headlamp
latestTag=$(git tag --list --sort=version:refname 'v*' | tail -1)
echo "LATEST_HEADLAMP_TAG=$latestTag" >> $GITHUB_ENV
echo $latestTag
- name: Sync minikube fork from upstream
run: |
gh repo sync headlamp-k8s/minikube
env:
GITHUB_TOKEN: ${{ secrets. KINVOLK_REPOS_TOKEN }}
- name: Check out minikube repo
uses: actions/checkout@v4
with:
repository: headlamp-k8s/minikube
path: minikube
token: ${{ secrets. KINVOLK_REPOS_TOKEN }}
fetch-depth: 0
- name: Update headlamp version in minikube
run: |
user=${{github.actor}}
if [ -z $user ]; then
user=yolossn
fi
HEADLAMP_VERSION=${LATEST_HEADLAMP_TAG:1}
LATEST_HEADLAMP_SHA=$(gh api \
"/orgs/headlamp-k8s/packages/container/headlamp/versions" --jq "map(select(.metadata.container.tags[] | contains(\"$LATEST_HEADLAMP_TAG\"))) | .[].name")
echo $LATEST_HEADLAMP_SHA
cd minikube
if git branch -l | grep -q "update_headlamp_$HEADLAMP_VERSION"; then
echo "deleting old branch from local to avoid conflict"
git branch -D "update_headlamp_$HEADLAMP_VERSION"
fi
if git branch -a | grep -q "origin/update_headlamp_$HEADLAMP_VERSION"; then
echo "deleting old branch from remote to avoid conflict"
git push origin --delete "update_headlamp_$HEADLAMP_VERSION"
fi
git checkout -b "update_headlamp_$HEADLAMP_VERSION"
sed -i "s/headlamp-k8s\/headlamp:v.*/headlamp-k8s\/headlamp:$LATEST_HEADLAMP_TAG@$LATEST_HEADLAMP_SHA\",/g" ./pkg/minikube/assets/addons.go
git diff
git add ./pkg/minikube/assets/addons.go
git status
git commit --signoff -m "Update Headlamp container version to $HEADLAMP_VERSION"
git status
git log -1
git push origin "update_headlamp_$HEADLAMP_VERSION" -f
gh pr create \
--title "Upgrade Headlamp version to $HEADLAMP_VERSION" \
--repo "kubernetes/minikube" \
--head "headlamp-k8s:update_headlamp_$HEADLAMP_VERSION" \
--base "master" \
--assignee "$user" \
--body "Upgrade Headlamp version to $HEADLAMP_VERSION
cc: @$user" \
env:
LATEST_HEADLAMP_TAG: ${{ env.LATEST_HEADLAMP_TAG }}
GITHUB_TOKEN: ${{ secrets. KINVOLK_REPOS_TOKEN }}