Skip to content

Create PRs for new versions of parts #8

Create PRs for new versions of parts

Create PRs for new versions of parts #8

name: Create PRs for new versions of parts
on:
workflow_dispatch:
schedule:
- cron: "0 10 * * *"
jobs:
update-versions:
runs-on: ubuntu-latest
strategy:
matrix:
part: ["cni", "containerd", "helm", "runc"]
steps:
- name: Checking out repo
uses: actions/checkout@v4
with:
ref: main
- name: Fetch and filter upstream tags
id: fetch-upstream
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -qq update
sudo apt-get -qq install -y jq
repository="$(cat "build-scripts/components/${{ matrix.part }}/repository")"
current_tag="$("build-scripts/components/${{ matrix.part }}/version.sh")"
IFS='.' read -r -a current_tag_parts <<< "$current_tag"
git clone $repository part
# Get the latest tag for major version, excluding -rc etc.
latest_tag="$(git -C part tag --sort=-v:refname | grep "${current_tag_parts[0]}" | grep -vE "-" | head -n 1)"
rm -rf part
if dpkg --compare-versions "${latest_tag:1}" "gt" "${current_tag:1}" ; then
echo "Found newer tag $latest_tag"
echo "new-tag=$latest_tag" >> $GITHUB_OUTPUT
sed -i "/echo/c\\echo \"$latest_tag\"" "build-scripts/components/${{ matrix.part }}/version.sh"
fi
- name: Create pull request
uses: peter-evans/create-pull-request@v6
with:
commit-message: Update ${{ matrix.part }} version to ${{ steps.fetch-upstream.outputs.new-tag }}
title: "[${{ matrix.part }}] Update version to ${{ steps.fetch-upstream.outputs.new-tag }}"
body: Update ${{ matrix.part }} version to ${{ steps.fetch-upstream.outputs.new-tag }}
branch: update/${{ matrix.part }}-${{ steps.fetch-upstream.outputs.new-tag }}
base: main