From 5ba3805a3f0bb4ed7afb759331de50744e0cd885 Mon Sep 17 00:00:00 2001 From: Bassem Dghaidi <568794+Link-@users.noreply.github.com> Date: Fri, 12 May 2023 11:52:24 +0200 Subject: [PATCH] Fix update runners scheduled workflow to check for container-hooks upgrades (#2576) --- .github/workflows/release-runners.yaml | 21 +++-- .github/workflows/update-runners.yaml | 82 ++++++++++++++----- runner/Makefile | 2 +- runner/VERSION | 3 +- ...nner-dind-rootless.ubuntu-20.04.dockerfile | 2 +- ...nner-dind-rootless.ubuntu-22.04.dockerfile | 2 +- ...ctions-runner-dind.ubuntu-20.04.dockerfile | 2 +- ...ctions-runner-dind.ubuntu-22.04.dockerfile | 2 +- runner/actions-runner.ubuntu-20.04.dockerfile | 2 +- runner/actions-runner.ubuntu-22.04.dockerfile | 2 +- 10 files changed, 82 insertions(+), 38 deletions(-) diff --git a/.github/workflows/release-runners.yaml b/.github/workflows/release-runners.yaml index 7a2334fada..ca39e185ad 100644 --- a/.github/workflows/release-runners.yaml +++ b/.github/workflows/release-runners.yaml @@ -1,4 +1,4 @@ -name: Runners +name: Release Runner Images # Revert to https://github.com/actions-runner-controller/releases#releases # for details on why we use this approach @@ -18,7 +18,6 @@ env: TARGET_ORG: actions-runner-controller TARGET_WORKFLOW: release-runners.yaml DOCKER_VERSION: 20.10.23 - RUNNER_CONTAINER_HOOKS_VERSION: 0.2.0 jobs: build-runners: @@ -27,10 +26,12 @@ jobs: steps: - uses: actions/checkout@v3 - name: Get runner version - id: runner_version + id: versions run: | - version=$(echo -n $(cat runner/VERSION)) - echo runner_version=$version >> $GITHUB_OUTPUT + runner_current_version="$(echo -n $(cat runner/VERSION | grep 'RUNNER_VERSION=' | cut -d '=' -f2))" + container_hooks_current_version="$(echo -n $(cat runner/VERSION | grep 'RUNNER_CONTAINER_HOOKS_VERSION=' | cut -d '=' -f2))" + echo runner_version=$runner_current_version >> $GITHUB_OUTPUT + echo container_hooks_version=$container_hooks_current_version >> $GITHUB_OUTPUT - name: Get Token id: get_workflow_token @@ -42,7 +43,8 @@ jobs: - name: Trigger Build And Push Runner Images To Registries env: - RUNNER_VERSION: ${{ steps.runner_version.outputs.runner_version }} + RUNNER_VERSION: ${{ steps.versions.outputs.runner_version }} + CONTAINER_HOOKS_VERSION: ${{ steps.versions.outputs.container_hooks_version }} run: | # Authenticate gh auth login --with-token <<< ${{ steps.get_workflow_token.outputs.token }} @@ -51,20 +53,21 @@ jobs: gh workflow run ${{ env.TARGET_WORKFLOW }} -R ${{ env.TARGET_ORG }}/releases \ -f runner_version=${{ env.RUNNER_VERSION }} \ -f docker_version=${{ env.DOCKER_VERSION }} \ - -f runner_container_hooks_version=${{ env.RUNNER_CONTAINER_HOOKS_VERSION }} \ + -f runner_container_hooks_version=${{ env.CONTAINER_HOOKS_VERSION }} \ -f sha='${{ github.sha }}' \ -f push_to_registries=${{ env.PUSH_TO_REGISTRIES }} - name: Job summary env: - RUNNER_VERSION: ${{ steps.runner_version.outputs.runner_version }} + RUNNER_VERSION: ${{ steps.versions.outputs.runner_version }} + CONTAINER_HOOKS_VERSION: ${{ steps.versions.outputs.container_hooks_version }} run: | echo "The [release-runners.yaml](https://github.com/actions-runner-controller/releases/blob/main/.github/workflows/release-runners.yaml) workflow has been triggered!" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "**Parameters:**" >> $GITHUB_STEP_SUMMARY echo "- runner_version: ${{ env.RUNNER_VERSION }}" >> $GITHUB_STEP_SUMMARY echo "- docker_version: ${{ env.DOCKER_VERSION }}" >> $GITHUB_STEP_SUMMARY - echo "- runner_container_hooks_version: ${{ env.RUNNER_CONTAINER_HOOKS_VERSION }}" >> $GITHUB_STEP_SUMMARY + echo "- runner_container_hooks_version: ${{ env.CONTAINER_HOOKS_VERSION }}" >> $GITHUB_STEP_SUMMARY echo "- sha: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY echo "- push_to_registries: ${{ env.PUSH_TO_REGISTRIES }}" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/update-runners.yaml b/.github/workflows/update-runners.yaml index cf39ee1d99..1fc896ec91 100644 --- a/.github/workflows/update-runners.yaml +++ b/.github/workflows/update-runners.yaml @@ -16,21 +16,34 @@ jobs: env: GH_TOKEN: ${{ github.token }} outputs: - current_version: ${{ steps.versions.outputs.current_version }} - latest_version: ${{ steps.versions.outputs.latest_version }} + runner_current_version: ${{ steps.runner_versions.outputs.runner_current_version }} + runner_latest_version: ${{ steps.runner_versions.outputs.runner_latest_version }} + container_hooks_current_version: ${{ steps.container_hooks_versions.outputs.container_hooks_current_version }} + container_hooks_latest_version: ${{ steps.container_hooks_versions.outputs.container_hooks_latest_version }} steps: - uses: actions/checkout@v3 - - name: Get current and latest versions - id: versions + - name: Get runner current and latest versions + id: runner_versions run: | - CURRENT_VERSION=$(echo -n $(cat runner/VERSION)) + CURRENT_VERSION="$(echo -n $(cat runner/VERSION | grep 'RUNNER_VERSION=' | cut -d '=' -f2))" echo "Current version: $CURRENT_VERSION" - echo current_version=$CURRENT_VERSION >> $GITHUB_OUTPUT + echo runner_current_version=$CURRENT_VERSION >> $GITHUB_OUTPUT LATEST_VERSION=$(gh release list --exclude-drafts --exclude-pre-releases --limit 1 -R actions/runner | grep -oP '(?<=v)[0-9.]+' | head -1) echo "Latest version: $LATEST_VERSION" - echo latest_version=$LATEST_VERSION >> $GITHUB_OUTPUT + echo runner_latest_version=$LATEST_VERSION >> $GITHUB_OUTPUT + + - name: Get container-hooks current and latest versions + id: container_hooks_versions + run: | + CURRENT_VERSION="$(echo -n $(cat runner/VERSION | grep 'RUNNER_CONTAINER_HOOKS_VERSION=' | cut -d '=' -f2))" + echo "Current version: $CURRENT_VERSION" + echo container_hooks_current_version=$CURRENT_VERSION >> $GITHUB_OUTPUT + + LATEST_VERSION=$(gh release list --exclude-drafts --exclude-pre-releases --limit 1 -R actions/runner-container-hooks | grep -oP '(?<=v)[0-9.]+' | head -1) + echo "Latest version: $LATEST_VERSION" + echo container_hooks_latest_version=$LATEST_VERSION >> $GITHUB_OUTPUT # check_pr checks if a PR for the same update already exists. It only runs if # runner latest version != our current version. If no existing PR is found, @@ -38,7 +51,7 @@ jobs: check_pr: runs-on: ubuntu-latest needs: check_versions - if: needs.check_versions.outputs.current_version != needs.check_versions.outputs.latest_version + if: needs.check_versions.outputs.runner_current_version != needs.check_versions.outputs.runner_latest_version || needs.check_versions.outputs.container_hooks_current_version != needs.check_versions.outputs.container_hooks_latest_version outputs: pr_name: ${{ steps.pr_name.outputs.pr_name }} env: @@ -46,17 +59,36 @@ jobs: steps: - name: debug run: - echo ${{ needs.check_versions.outputs.current_version }} - echo ${{ needs.check_versions.outputs.latest_version }} + echo "RUNNER_CURRENT_VERSION=${{ needs.check_versions.outputs.runner_current_version }}" + echo "RUNNER_LATEST_VERSION=${{ needs.check_versions.outputs.runner_latest_version }}" + echo "CONTAINER_HOOKS_CURRENT_VERSION=${{ needs.check_versions.outputs.container_hooks_current_version }}" + echo "CONTAINER_HOOKS_LATEST_VERSION=${{ needs.check_versions.outputs.container_hooks_latest_version }}" + - uses: actions/checkout@v3 - name: PR Name id: pr_name env: - LATEST_VERSION: ${{ needs.check_versions.outputs.latest_version }} + RUNNER_CURRENT_VERSION: ${{ needs.check_versions.outputs.runner_current_version }} + RUNNER_LATEST_VERSION: ${{ needs.check_versions.outputs.runner_latest_version }} + CONTAINER_HOOKS_CURRENT_VERSION: ${{ needs.check_versions.outputs.container_hooks_current_version }} + CONTAINER_HOOKS_LATEST_VERSION: ${{ needs.check_versions.outputs.container_hooks_latest_version }} + # Generate a PR name with the following title: + # Updates: runner to v2.304.0 and container-hooks to v0.3.1 run: | - PR_NAME="Update runner to version ${LATEST_VERSION}" - + RUNNER_MESSAGE="runner to v${RUNNER_LATEST_VERSION}" + CONTAINER_HOOKS_MESSAGE="container-hooks to v${CONTAINER_HOOKS_LATEST_VERSION}" + + PR_NAME="Updates:" + if [ "$RUNNER_CURRENT_VERSION" != "$RUNNER_LATEST_VERSION" ] + then + PR_NAME="$PR_NAME $RUNNER_MESSAGE" + fi + if [ "$CONTAINER_HOOKS_CURRENT_VERSION" != "$CONTAINER_HOOKS_LATEST_VERSION" ] + then + PR_NAME="$PR_NAME $CONTAINER_HOOKS_MESSAGE" + fi + result=$(gh pr list --search "$PR_NAME" --json number --jq ".[].number" --limit 1) if [ -z "$result" ] then @@ -80,21 +112,29 @@ jobs: actions: write env: GH_TOKEN: ${{ github.token }} - CURRENT_VERSION: ${{ needs.check_versions.outputs.current_version }} - LATEST_VERSION: ${{ needs.check_versions.outputs.latest_version }} + RUNNER_CURRENT_VERSION: ${{ needs.check_versions.outputs.runner_current_version }} + RUNNER_LATEST_VERSION: ${{ needs.check_versions.outputs.runner_latest_version }} + CONTAINER_HOOKS_CURRENT_VERSION: ${{ needs.check_versions.outputs.container_hooks_current_version }} + CONTAINER_HOOKS_LATEST_VERSION: ${{ needs.check_versions.outputs.container_hooks_latest_version }} PR_NAME: ${{ needs.check_pr.outputs.pr_name }} steps: - uses: actions/checkout@v3 + - name: New branch - run: git checkout -b update-runner-$LATEST_VERSION + run: git checkout -b update-runner-"$(date +%Y-%m-%d)" + - name: Update files run: | - sed -i "s/$CURRENT_VERSION/$LATEST_VERSION/g" runner/VERSION - sed -i "s/$CURRENT_VERSION/$LATEST_VERSION/g" runner/Makefile - sed -i "s/$CURRENT_VERSION/$LATEST_VERSION/g" Makefile - sed -i "s/$CURRENT_VERSION/$LATEST_VERSION/g" test/e2e/e2e_test.go - sed -i "s/$CURRENT_VERSION/$LATEST_VERSION/g" .github/workflows/e2e-test-linux-vm.yaml + sed -i "s/$RUNNER_CURRENT_VERSION/$RUNNER_LATEST_VERSION/g" runner/VERSION + sed -i "s/$RUNNER_CURRENT_VERSION/$RUNNER_LATEST_VERSION/g" runner/Makefile + sed -i "s/$RUNNER_CURRENT_VERSION/$RUNNER_LATEST_VERSION/g" Makefile + sed -i "s/$RUNNER_CURRENT_VERSION/$RUNNER_LATEST_VERSION/g" test/e2e/e2e_test.go + + sed -i "s/$CONTAINER_HOOKS_CURRENT_VERSION/$CONTAINER_HOOKS_LATEST_VERSION/g" runner/VERSION + sed -i "s/$CONTAINER_HOOKS_CURRENT_VERSION/$CONTAINER_HOOKS_LATEST_VERSION/g" runner/Makefile + sed -i "s/$CONTAINER_HOOKS_CURRENT_VERSION/$CONTAINER_HOOKS_LATEST_VERSION/g" Makefile + sed -i "s/$CONTAINER_HOOKS_CURRENT_VERSION/$CONTAINER_HOOKS_LATEST_VERSION/g" test/e2e/e2e_test.go - name: Commit changes run: | diff --git a/runner/Makefile b/runner/Makefile index d404ab4843..a6ac424606 100644 --- a/runner/Makefile +++ b/runner/Makefile @@ -6,7 +6,7 @@ DIND_ROOTLESS_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner-dind-rootless OS_IMAGE ?= ubuntu-22.04 TARGETPLATFORM ?= $(shell arch) -RUNNER_VERSION ?= 2.304.0 +RUNNER_VERSION ?= 2.304.0 RUNNER_CONTAINER_HOOKS_VERSION ?= 0.2.0 DOCKER_VERSION ?= 20.10.23 diff --git a/runner/VERSION b/runner/VERSION index 971440973d..591bddba99 100644 --- a/runner/VERSION +++ b/runner/VERSION @@ -1 +1,2 @@ -2.304.0 +RUNNER_VERSION=2.304.0 +RUNNER_CONTAINER_HOOKS_VERSION=0.2.0 \ No newline at end of file diff --git a/runner/actions-runner-dind-rootless.ubuntu-20.04.dockerfile b/runner/actions-runner-dind-rootless.ubuntu-20.04.dockerfile index 33d3c3d22e..f8875bc9e2 100644 --- a/runner/actions-runner-dind-rootless.ubuntu-20.04.dockerfile +++ b/runner/actions-runner-dind-rootless.ubuntu-20.04.dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:20.04 ARG TARGETPLATFORM ARG RUNNER_VERSION -ARG RUNNER_CONTAINER_HOOKS_VERSION=0.2.0 +ARG RUNNER_CONTAINER_HOOKS_VERSION # Docker and Docker Compose arguments ENV CHANNEL=stable ARG DOCKER_COMPOSE_VERSION=v2.16.0 diff --git a/runner/actions-runner-dind-rootless.ubuntu-22.04.dockerfile b/runner/actions-runner-dind-rootless.ubuntu-22.04.dockerfile index 3e35d183fd..06621bd7a6 100644 --- a/runner/actions-runner-dind-rootless.ubuntu-22.04.dockerfile +++ b/runner/actions-runner-dind-rootless.ubuntu-22.04.dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:22.04 ARG TARGETPLATFORM ARG RUNNER_VERSION -ARG RUNNER_CONTAINER_HOOKS_VERSION=0.2.0 +ARG RUNNER_CONTAINER_HOOKS_VERSION # Docker and Docker Compose arguments ENV CHANNEL=stable ARG DOCKER_COMPOSE_VERSION=v2.16.0 diff --git a/runner/actions-runner-dind.ubuntu-20.04.dockerfile b/runner/actions-runner-dind.ubuntu-20.04.dockerfile index 053ccc1c1b..c69d3e0903 100644 --- a/runner/actions-runner-dind.ubuntu-20.04.dockerfile +++ b/runner/actions-runner-dind.ubuntu-20.04.dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:20.04 ARG TARGETPLATFORM ARG RUNNER_VERSION -ARG RUNNER_CONTAINER_HOOKS_VERSION=0.2.0 +ARG RUNNER_CONTAINER_HOOKS_VERSION # Docker and Docker Compose arguments ARG CHANNEL=stable ARG DOCKER_VERSION=20.10.23 diff --git a/runner/actions-runner-dind.ubuntu-22.04.dockerfile b/runner/actions-runner-dind.ubuntu-22.04.dockerfile index 6ee33dd236..03ee37a2a1 100644 --- a/runner/actions-runner-dind.ubuntu-22.04.dockerfile +++ b/runner/actions-runner-dind.ubuntu-22.04.dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:22.04 ARG TARGETPLATFORM ARG RUNNER_VERSION -ARG RUNNER_CONTAINER_HOOKS_VERSION=0.2.0 +ARG RUNNER_CONTAINER_HOOKS_VERSION # Docker and Docker Compose arguments ARG CHANNEL=stable ARG DOCKER_VERSION=20.10.23 diff --git a/runner/actions-runner.ubuntu-20.04.dockerfile b/runner/actions-runner.ubuntu-20.04.dockerfile index 83d55bbab6..a5c7d0a40c 100644 --- a/runner/actions-runner.ubuntu-20.04.dockerfile +++ b/runner/actions-runner.ubuntu-20.04.dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:20.04 ARG TARGETPLATFORM ARG RUNNER_VERSION -ARG RUNNER_CONTAINER_HOOKS_VERSION=0.2.0 +ARG RUNNER_CONTAINER_HOOKS_VERSION # Docker and Docker Compose arguments ARG CHANNEL=stable ARG DOCKER_VERSION=20.10.23 diff --git a/runner/actions-runner.ubuntu-22.04.dockerfile b/runner/actions-runner.ubuntu-22.04.dockerfile index b0e5fcea2e..82a43d2ca3 100644 --- a/runner/actions-runner.ubuntu-22.04.dockerfile +++ b/runner/actions-runner.ubuntu-22.04.dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:22.04 ARG TARGETPLATFORM ARG RUNNER_VERSION -ARG RUNNER_CONTAINER_HOOKS_VERSION=0.2.0 +ARG RUNNER_CONTAINER_HOOKS_VERSION # Docker and Docker Compose arguments ARG CHANNEL=stable ARG DOCKER_VERSION=20.10.23