mirror of
https://github.com/actions/runner.git
synced 2025-12-12 15:13:30 +00:00
Dockerfile and workflow change for runner image (#2250)
* Workflow * add back github-token to id:image * added handle to image name * removed core require * multi line added :latest * added label * added repository_owner in IMAGE_NAME * with the release * release * markdown label description * Remove markdown desciprion * Remove double quotes in labels * Reverted back releaseVersion
This commit is contained in:
65
.github/workflows/publish-image.yml
vendored
Normal file
65
.github/workflows/publish-image.yml
vendored
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
name: Publish Runner Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
runnerVersion:
|
||||||
|
type: string
|
||||||
|
description: Version of the runner being installed
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository_owner }}/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@v6
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
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 }}
|
||||||
|
${{ 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
|
||||||
49
.github/workflows/release.yml
vendored
49
.github/workflows/release.yml
vendored
@@ -660,3 +660,52 @@ jobs:
|
|||||||
asset_path: ${{ github.workspace }}/linux-arm64-trimmedpackages.json
|
asset_path: ${{ github.workspace }}/linux-arm64-trimmedpackages.json
|
||||||
asset_name: actions-runner-linux-arm64-${{ steps.releaseNote.outputs.version }}-trimmedpackages.json
|
asset_name: actions-runner-linux-arm64-${{ steps.releaseNote.outputs.version }}-trimmedpackages.json
|
||||||
asset_content_type: application/octet-stream
|
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
|
||||||
|
|||||||
21
images/Dockerfile
Normal file
21
images/Dockerfile
Normal file
@@ -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 .
|
||||||
Reference in New Issue
Block a user