Publish Runner Image #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Lowercase the IMAGE_NAME | |
run: | | |
echo "IMAGE_NAME=${IMAGE_NAME,,}" >> $GITHUB_ENV | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Compute image version | |
id: image | |
uses: actions/github-script@v6 | |
env: | |
RUNNER_VERSION: ${{ github.event.inputs.runnerVersion }} | |
with: | |
script: | | |
const fs = require('fs'); | |
const inputRunnerVersion = process.env.RUNNER_VERSION; | |
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 | |
platforms: | | |
linux/amd64 | |
linux/arm64 | |
tags: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.image.outputs.version }} | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
build-args: | | |
RUNNER_VERSION=${{ steps.image.outputs.version }} | |
RUNNER_REPO=${{ github.repository_owner }} | |
push: true | |
labels: | | |
org.opencontainers.image.title=GitHub Actions Runner | |
org.opencontainers.image.description=https://github.com/${{ github.repository_owner }}/runner/releases/tag/v${{ steps.image.outputs.version }} | |
org.opencontainers.image.licenses=MIT |