Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/updatecli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "Updatecli: Detect new RKE2 releases"

on:
schedule:
# Runs at 06:00 AM UTC every day
- cron: '0 6 * * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: write
issues: write
pull-requests: write

jobs:
updatecli:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: dev-v2.13

- name: Install Updatecli
uses: updatecli/updatecli-action@v2

- name: Delete leftover UpdateCLI branches
run: |
gh pr list \
--search "is:closed is:pr head:updatecli_" \
--json headRefName \
--jq ".[].headRefName" | sort -u > closed_prs_branches.txt
gh pr list \
--search "is:open is:pr head:updatecli_" \
--json headRefName \
--jq ".[].headRefName" | sort -u > open_prs_branches.txt
for branch in $(comm -23 closed_prs_branches.txt open_prs_branches.txt); do
if (git ls-remote --exit-code --heads origin "$branch"); then
echo "Deleting leftover UpdateCLI branch - $branch";
git push origin --delete "$branch";
fi
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Apply Updatecli
# Never use '--debug' option, because it might leak the access tokens.
run: "updatecli apply --clean --config ./updatecli/updatecli.d/ --values ./updatecli/values.yaml"
env:
UPDATECLI_GITHUB_ACTOR: ${{ github.actor }}
UPDATECLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72 changes: 72 additions & 0 deletions updatecli/updatecli.d/rke2-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This updatecli manifest detects new RKE2 releases from github.com/rancher/rke2
# and opens a PR to update the kontainer-driver-metadata repository.
#
# To test this locally:
# have "UPDATECLI_GITHUB_ACTOR" env set to your github username
# have "UPDATECLI_GITHUB_TOKEN" env set to your github token
# have the latest version of updatecli installed
# 'updatecli diff --values updatecli/values.yaml --config updatecli/updatecli.d/rke2-release.yaml'
---
name: "Detect new RKE2 release"

scms:
kontainer-driver-metadata:
kind: "github"
spec:
user: "{{ .github.user }}"
email: "{{ .github.email }}"
username: "{{ requiredEnv .github.username }}"
token: '{{ requiredEnv .github.token }}'
owner: rancher
repository: kontainer-driver-metadata
branch: dev-v2.13

sources:
rke2-release:
name: "Get latest RKE2 release"
kind: "githubrelease"
spec:
owner: rancher
repository: rke2
token: '{{ requiredEnv .github.token }}'
username: '{{ requiredEnv .github.username }}'
typefilter:
release: true
draft: false
prerelease: false
versionfilter:
kind: regex
# pattern matches RKE2 release tags like v1.32.1+rke2r1
pattern: 'v[0-9]+\.[0-9]+\.[0-9]+\+rke2r[0-9]+'

conditions:
checkIfReleaseExists:
name: "Check if RKE2 release already exists in channels-rke2.yaml"
kind: file
disablesourceinput: true
spec:
file: channels-rke2.yaml
matchpattern: '{{ source "rke2-release" }}'
scmid: kontainer-driver-metadata
failwhen: true

actions:
github:
kind: "github/pullrequest"
scmid: "kontainer-driver-metadata"
spec:
automerge: false
draft: false
mergemethod: squash
title: 'New RKE2 release detected: {{ source "rke2-release" }}'
description: |
A new RKE2 release has been detected: **{{ source "rke2-release" }}**

This PR was automatically created by updatecli.

Please review and add the necessary configuration for this release to `channels-rke2.yaml`.

Release URL: https://github.com/rancher/rke2/releases/tag/{{ source "rke2-release" }}
labels:
- updatecli
- rke2
5 changes: 5 additions & 0 deletions updatecli/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
github:
user: "github-actions[bot]"
email: "41898282+github-actions[bot]@users.noreply.github.com"
username: "UPDATECLI_GITHUB_ACTOR"
token: "UPDATECLI_GITHUB_TOKEN"