Skip to content

Commit 3f9f6f3

Browse files
authored
Update workflow around runner docker image. (#4133)
1 parent 221f658 commit 3f9f6f3

File tree

3 files changed

+125
-1
lines changed

3 files changed

+125
-1
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/github-script@v8.0.0
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

0 commit comments

Comments
 (0)