From 628305d343a97f6c49502c8d3e073e4ddd16e910 Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:03:26 +0100 Subject: [PATCH 01/13] Workflow --- .github/workflows/publish-image.yml | 61 +++++++++++++++++++++++++++++ images/Dockerfile | 21 ++++++++++ 2 files changed, 82 insertions(+) create mode 100644 .github/workflows/publish-image.yml create mode 100644 images/Dockerfile diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml new file mode 100644 index 00000000000..dd027258e44 --- /dev/null +++ b/.github/workflows/publish-image.yml @@ -0,0 +1,61 @@ +name: Publish Runner Image + +on: + workflow_dispatch: + inputs: + runnerVersion: + type: string + description: Version of the runner being installed + +env: + REGISTRY: ghcr.io + IMAGE_NAME: actions-runner + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Compute image version + id: image + uses: actions/github-script@0.3.0 + with: + script: | + const core = require('@actions/core') + const fs = require('fs'); + const inputRunnerVersion = "${{ github.event.inputs.runnerVersion }}" + if (inputRunnerVersion) { + console.log(`Using input runner version ${inputRunnerVersion}`) + core.setOutput('version', inputRunnerVersion); + return + } + const runnerVersion = fs.readFileSync('${{ github.workspace }}/src/runnerversion', 'utf8').replace(/\n$/g, '') + console.log(`Using runner version ${runnerVersion}`) + core.setOutput('version', runnerVersion); + + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v2 + + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v3 + with: + context: ./images + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }} + build-args: | + RUNNER_VERSION=${{ steps.image.outputs.version }} + push: true + diff --git a/images/Dockerfile b/images/Dockerfile new file mode 100644 index 00000000000..411ce08eba2 --- /dev/null +++ b/images/Dockerfile @@ -0,0 +1,21 @@ +FROM mcr.microsoft.com/dotnet/runtime-deps:6.0 as build + +ARG RUNNER_VERSION +ARG RUNNER_ARCH="x64" +ARG RUNNER_CONTAINER_HOOKS_VERSION=0.1.3 + +RUN apt update -y && apt install curl unzip -y + +WORKDIR /actions-runner +RUN curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz \ + && tar xzf ./runner.tar.gz \ + && rm runner.tar.gz + +RUN curl -f -L -o runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v${RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-k8s-${RUNNER_CONTAINER_HOOKS_VERSION}.zip \ + && unzip ./runner-container-hooks.zip -d ./k8s \ + && rm runner-container-hooks.zip + +FROM mcr.microsoft.com/dotnet/runtime-deps:6.0 + +WORKDIR /actions-runner +COPY --from=build /actions-runner . From e9e0d8afbd9e6c828ec2ba5b385fb4787045e3c1 Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:05:14 +0100 Subject: [PATCH 02/13] add back github-token to id:image --- .github/workflows/publish-image.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index dd027258e44..8ee2dee620b 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -26,6 +26,7 @@ jobs: id: image uses: actions/github-script@0.3.0 with: + github-token: ${{secrets.GITHUB_TOKEN}} script: | const core = require('@actions/core') const fs = require('fs'); From b4f14893bc822366dd042d02bded7be08c0af881 Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:08:16 +0100 Subject: [PATCH 03/13] added handle to image name --- .github/workflows/publish-image.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 8ee2dee620b..393af37913f 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -9,7 +9,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: actions-runner + IMAGE_NAME: nikola-jokic/actions-runner jobs: build: @@ -24,9 +24,8 @@ jobs: - name: Compute image version id: image - uses: actions/github-script@0.3.0 + uses: actions/github-script@v6 with: - github-token: ${{secrets.GITHUB_TOKEN}} script: | const core = require('@actions/core') const fs = require('fs'); From 221941018827fe4e2595953b2534393394a35f30 Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:10:28 +0100 Subject: [PATCH 04/13] removed core require --- .github/workflows/publish-image.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 393af37913f..69138a2a9cb 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -27,7 +27,6 @@ jobs: uses: actions/github-script@v6 with: script: | - const core = require('@actions/core') const fs = require('fs'); const inputRunnerVersion = "${{ github.event.inputs.runnerVersion }}" if (inputRunnerVersion) { From 8a4d71fb1da116ffd98fd3f569c89fa5430de4dd Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:14:05 +0100 Subject: [PATCH 05/13] multi line added :latest --- .github/workflows/publish-image.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 69138a2a9cb..8a6af43b683 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -53,7 +53,9 @@ jobs: uses: docker/build-push-action@v3 with: context: ./images - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }} + tags: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest build-args: | RUNNER_VERSION=${{ steps.image.outputs.version }} push: true From 2dc84cc0181cd9890ff28df0a98dbfe1163cfb15 Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:21:09 +0100 Subject: [PATCH 06/13] added label --- .github/workflows/publish-image.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 8a6af43b683..4fbe3c1adc9 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -59,4 +59,6 @@ jobs: build-args: | RUNNER_VERSION=${{ steps.image.outputs.version }} push: true + labels: | + org.opencontainers.image.source="https://github.com/nikola-jokic/runner" From 668cb24b549556935b34afb98362baeaa304e270 Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:25:38 +0100 Subject: [PATCH 07/13] added repository_owner in IMAGE_NAME --- .github/workflows/publish-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 4fbe3c1adc9..0b141eb91de 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -9,7 +9,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: nikola-jokic/actions-runner + IMAGE_NAME: ${{ github.repository_owner }}/actions-runner jobs: build: @@ -60,5 +60,5 @@ jobs: RUNNER_VERSION=${{ steps.image.outputs.version }} push: true labels: | - org.opencontainers.image.source="https://github.com/nikola-jokic/runner" + org.opencontainers.image.source="${{github.server_url}}/${{github.repository}}" From f1e14a2c2f19267883e78f7e8b2bc66b3454339a Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:36:40 +0100 Subject: [PATCH 08/13] with the release --- .github/workflows/publish-image.yml | 3 +- .github/workflows/release.yml | 49 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 0b141eb91de..447f4ee999f 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -61,4 +61,5 @@ jobs: push: true labels: | org.opencontainers.image.source="${{github.server_url}}/${{github.repository}}" - + org.opencontainers.image.description="https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}" + org.opencontainers.image.licenses="MIT" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index abad70edaa7..43932625235 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -660,3 +660,52 @@ jobs: asset_path: ${{ github.workspace }}/linux-arm64-trimmedpackages.json asset_name: actions-runner-linux-arm64-${{ steps.releaseNote.outputs.version }}-trimmedpackages.json asset_content_type: application/octet-stream + + publish-image: + needs: release + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository_owner }}/actions-runner + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Compute image version + id: image + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + const runnerVersion = fs.readFileSync('${{ github.workspace }}/releaseVersion', 'utf8').replace(/\n$/g, '') + console.log(`Using runner version ${runnerVersion}`) + core.setOutput('version', runnerVersion); + + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v2 + + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v3 + with: + context: ./images + tags: | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + build-args: | + RUNNER_VERSION=${{ steps.image.outputs.version }} + push: true + labels: | + org.opencontainers.image.source="${{github.server_url}}/${{github.repository}}" + org.opencontainers.image.description="https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}" + org.opencontainers.image.licenses="MIT" From 14c8a551a30faec4ac9a0b6b08e5029aed21bc7c Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:39:45 +0100 Subject: [PATCH 09/13] release --- releaseVersion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releaseVersion b/releaseVersion index ef96e25e847..bf5c74669fd 100644 --- a/releaseVersion +++ b/releaseVersion @@ -1 +1 @@ - +2.299.0 From 18aaa434509ed3451cdc09df7bd0a08d570b7da5 Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:50:19 +0100 Subject: [PATCH 10/13] markdown label description --- .github/workflows/publish-image.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 447f4ee999f..42892784923 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -61,5 +61,5 @@ jobs: push: true labels: | org.opencontainers.image.source="${{github.server_url}}/${{github.repository}}" - org.opencontainers.image.description="https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}" + org.opencontainers.image.description=[Release Note](https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}) org.opencontainers.image.licenses="MIT" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 43932625235..1acea9fa499 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -707,5 +707,5 @@ jobs: push: true labels: | org.opencontainers.image.source="${{github.server_url}}/${{github.repository}}" - org.opencontainers.image.description="https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}" + org.opencontainers.image.description=[Release Note](https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}) org.opencontainers.image.licenses="MIT" From be762cc44f19399149149d0ad30a1014f1214748 Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:52:28 +0100 Subject: [PATCH 11/13] Remove markdown desciprion --- .github/workflows/publish-image.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 42892784923..05dc3162897 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -61,5 +61,5 @@ jobs: push: true labels: | org.opencontainers.image.source="${{github.server_url}}/${{github.repository}}" - org.opencontainers.image.description=[Release Note](https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}) + org.opencontainers.image.description=https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }} org.opencontainers.image.licenses="MIT" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1acea9fa499..c35ffad327c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -707,5 +707,5 @@ jobs: push: true labels: | org.opencontainers.image.source="${{github.server_url}}/${{github.repository}}" - org.opencontainers.image.description=[Release Note](https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}) + org.opencontainers.image.description=https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }} org.opencontainers.image.licenses="MIT" From 4b399149c74ba0282c87dce94aad328c8444e446 Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:54:04 +0100 Subject: [PATCH 12/13] Remove double quotes in labels --- .github/workflows/publish-image.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 05dc3162897..bf0dbfc27e8 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -60,6 +60,6 @@ jobs: RUNNER_VERSION=${{ steps.image.outputs.version }} push: true labels: | - org.opencontainers.image.source="${{github.server_url}}/${{github.repository}}" + org.opencontainers.image.source=${{github.server_url}}/${{github.repository}} org.opencontainers.image.description=https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }} - org.opencontainers.image.licenses="MIT" + org.opencontainers.image.licenses=MIT diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c35ffad327c..ad9f0d77fa9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -706,6 +706,6 @@ jobs: RUNNER_VERSION=${{ steps.image.outputs.version }} push: true labels: | - org.opencontainers.image.source="${{github.server_url}}/${{github.repository}}" + org.opencontainers.image.source=${{github.server_url}}/${{github.repository}} org.opencontainers.image.description=https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }} - org.opencontainers.image.licenses="MIT" + org.opencontainers.image.licenses=MIT From 6128b057adfabfe3a14180fb3cc4d2af870af6e5 Mon Sep 17 00:00:00 2001 From: Nikola Jokic <97525037+nikola-jokic@users.noreply.github.com> Date: Thu, 10 Nov 2022 17:57:23 +0100 Subject: [PATCH 13/13] Reverted back releaseVersion --- releaseVersion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releaseVersion b/releaseVersion index bf5c74669fd..ef96e25e847 100644 --- a/releaseVersion +++ b/releaseVersion @@ -1 +1 @@ -2.299.0 +