Skip to content

Commit 89314e8

Browse files
authored
Merge branch 'main' into main
2 parents 2fe31d9 + 463496e commit 89314e8

File tree

4 files changed

+130
-6
lines changed

4 files changed

+130
-6
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ on:
1414
paths-ignore:
1515
- '**.md'
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
build:
1922
strategy:
@@ -80,3 +83,48 @@ jobs:
8083
name: runner-package-${{ matrix.runtime }}
8184
path: |
8285
_package
86+
87+
docker:
88+
strategy:
89+
matrix:
90+
os: [ ubuntu-latest, ubuntu-24.04-arm ]
91+
include:
92+
- os: ubuntu-latest
93+
docker_platform: linux/amd64
94+
- os: ubuntu-24.04-arm
95+
docker_platform: linux/arm64
96+
runs-on: ${{ matrix.os }}
97+
steps:
98+
- uses: actions/checkout@v5
99+
100+
- name: Get latest runner version
101+
id: latest_runner
102+
uses: actions/github-script@v7
103+
with:
104+
github-token: ${{secrets.GITHUB_TOKEN}}
105+
script: |
106+
const release = await github.rest.repos.getLatestRelease({
107+
owner: 'actions',
108+
repo: 'runner',
109+
});
110+
const version = release.data.tag_name.replace(/^v/, '');
111+
core.setOutput('version', version);
112+
113+
- name: Setup Docker buildx
114+
uses: docker/setup-buildx-action@v3
115+
116+
- name: Build Docker image
117+
uses: docker/build-push-action@v6
118+
with:
119+
context: ./images
120+
load: true
121+
platforms: ${{ matrix.docker_platform }}
122+
tags: |
123+
${{ github.sha }}:latest
124+
build-args: |
125+
RUNNER_VERSION=${{ steps.latest_runner.outputs.version }}
126+
127+
- name: Test Docker image
128+
run: |
129+
docker run --rm ${{ github.sha }}:latest ./run.sh --version
130+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Publish DockerImage from Release Branch
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseBranch:
7+
description: 'Release Branch (releases/mXXX)'
8+
required: true
9+
10+
jobs:
11+
publish-image:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
id-token: write
17+
attestations: write
18+
env:
19+
REGISTRY: ghcr.io
20+
IMAGE_NAME: ${{ github.repository_owner }}/actions-runner
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v5
24+
with:
25+
ref: ${{ github.event.inputs.releaseBranch }}
26+
27+
- name: Compute image version
28+
id: image
29+
uses: actions/[email protected]
30+
with:
31+
script: |
32+
const fs = require('fs');
33+
const runnerVersion = fs.readFileSync('${{ github.workspace }}/releaseVersion', 'utf8').replace(/\n$/g, '');
34+
console.log(`Using runner version ${runnerVersion}`);
35+
if (!/^\d+\.\d+\.\d+$/.test(runnerVersion)) {
36+
throw new Error(`Invalid runner version: ${runnerVersion}`);
37+
}
38+
core.setOutput('version', runnerVersion);
39+
40+
- name: Setup Docker buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: Log into registry ${{ env.REGISTRY }}
44+
uses: docker/login-action@v3
45+
with:
46+
registry: ${{ env.REGISTRY }}
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Build and push Docker image
51+
id: build-and-push
52+
uses: docker/build-push-action@v6
53+
with:
54+
context: ./images
55+
platforms: |
56+
linux/amd64
57+
linux/arm64
58+
tags: |
59+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }}
60+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
61+
build-args: |
62+
RUNNER_VERSION=${{ steps.image.outputs.version }}
63+
push: true
64+
labels: |
65+
org.opencontainers.image.source=${{github.server_url}}/${{github.repository}}
66+
org.opencontainers.image.licenses=MIT
67+
annotations: |
68+
org.opencontainers.image.description=https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}
69+
70+
- name: Generate attestation
71+
uses: actions/attest-build-provenance@v3
72+
with:
73+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
74+
subject-digest: ${{ steps.build-and-push.outputs.digest }}
75+
push-to-registry: true

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,9 @@ jobs:
334334
push: true
335335
labels: |
336336
org.opencontainers.image.source=${{github.server_url}}/${{github.repository}}
337-
org.opencontainers.image.description=https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}
338337
org.opencontainers.image.licenses=MIT
338+
annotations: |
339+
org.opencontainers.image.description=https://github.com/actions/runner/releases/tag/v${{ steps.image.outputs.version }}
339340
340341
- name: Generate attestation
341342
uses: actions/attest-build-provenance@v3

images/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ARG TARGETOS
55
ARG TARGETARCH
66
ARG RUNNER_VERSION
77
ARG RUNNER_CONTAINER_HOOKS_VERSION=0.7.0
8-
ARG DOCKER_VERSION=29.0.1
9-
ARG BUILDX_VERSION=0.30.0
8+
ARG DOCKER_VERSION=29.0.2
9+
ARG BUILDX_VERSION=0.30.1
1010

1111
RUN apt update -y && apt install curl unzip -y
1212

@@ -33,7 +33,7 @@ RUN export RUNNER_ARCH=${TARGETARCH} \
3333
&& rm -rf docker.tgz \
3434
&& mkdir -p /usr/local/lib/docker/cli-plugins \
3535
&& curl -fLo /usr/local/lib/docker/cli-plugins/docker-buildx \
36-
"https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-${TARGETARCH}" \
36+
"https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-${TARGETARCH}" \
3737
&& chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx
3838

3939
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy
@@ -54,8 +54,6 @@ RUN add-apt-repository ppa:git-core/ppa \
5454
&& apt install -y git \
5555
&& rm -rf /var/lib/apt/lists/*
5656

57-
WORKDIR /home/runner
58-
5957
RUN adduser --disabled-password --gecos "" --uid 1001 runner \
6058
&& groupadd docker --gid 123 \
6159
&& usermod -aG sudo runner \
@@ -64,6 +62,8 @@ RUN adduser --disabled-password --gecos "" --uid 1001 runner \
6462
&& echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers \
6563
&& chmod 777 /home/runner
6664

65+
WORKDIR /home/runner
66+
6767
COPY --chown=runner:docker --from=build /actions-runner .
6868
COPY --from=build /usr/local/lib/docker/cli-plugins/docker-buildx /usr/local/lib/docker/cli-plugins/docker-buildx
6969

0 commit comments

Comments
 (0)