Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/actions/setup-docker-environment/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
ghcr_password:
description: "GHCR password. Usually set from the secrets.GITHUB_TOKEN variable"
required: true
platform:
description: "Platform (either linux or windows)."
default: linux
required: false

runs:
using: "composite"
Expand All @@ -24,9 +28,11 @@ runs:
shell: bash

- name: Set up QEMU
if: inputs.platform == 'linux'
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
if: inputs.platform == 'linux'
uses: docker/setup-buildx-action@v2
with:
version: latest
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/runners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,51 @@ jobs:
ghcr.io/${{ github.repository }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}-${{ env.sha_short }}
cache-from: type=gha,scope=build-${{ matrix.name }}
cache-to: type=gha,mode=max,scope=build-${{ matrix.name }}

build-runners-win2019:
name: Build ${{ matrix.name }}-${{ matrix.os-name }}-${{ matrix.os-version }}
runs-on: windows-2019
permissions:
packages: write
contents: read
strategy:
fail-fast: false
matrix:
include:
- name: actions-runner-windows
os-name: win
os-version: 2019
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Docker Environment
id: vars
uses: ./.github/actions/setup-docker-environment
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
ghcr_username: ${{ github.actor }}
ghcr_password: ${{ secrets.GITHUB_TOKEN }}
platform: windows
- name: Build
shell: bash
run: |
cd runner
docker build --build-arg RUNNER_VERSION=${{ env.RUNNER_VERSION }} -t ${{ matrix.name }} -f ${{ matrix.name }}.dockerfile .
- name: Tag and Push
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
shell: bash
run: |
tags=( \
"${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}" \
"${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}-${{ env.sha_short }}" \
"${{ env.DOCKERHUB_USERNAME }}/${{ matrix.name }}:latest" \
"ghcr.io/${{ github.repository }}/${{ matrix.name }}:latest" \
"ghcr.io/${{ github.repository }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}" \
"ghcr.io/${{ github.repository }}/${{ matrix.name }}:v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}-${{ env.sha_short }}" \
)

for tag in "${tags[@]}" ; do
docker tag ${{ matrix.name }}:latest "$tag"
docker push "$tag"
done
11 changes: 11 additions & 0 deletions runner/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DOCKER_USER ?= summerwind
DOCKER ?= docker
NAME ?= ${DOCKER_USER}/actions-runner
WIN_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner-windows
DIND_RUNNER_NAME ?= ${DOCKER_USER}/actions-runner-dind
TAG ?= latest
TARGETPLATFORM ?= $(shell arch)
Expand Down Expand Up @@ -65,3 +66,13 @@ docker-buildx-ubuntu:
-f actions-runner-dind.dockerfile \
-t "${DIND_RUNNER_NAME}:${TAG}" \
. ${PUSH_ARG}


docker-build-windows:
${DOCKER} build \
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \
-f actions-runner-windows.dockerfile \
-t ${WIN_RUNNER_NAME}:${TAG} .

docker-push-windows:
${DOCKER} push ${WIN_RUNNER_NAME}:${TAG}
20 changes: 20 additions & 0 deletions runner/actions-runner-windows.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2019

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"]

ARG RUNNER_VERSION=2.298.2

RUN Invoke-WebRequest \
-Uri 'https://aka.ms/install-powershell.ps1' \
-OutFile install-powershell.ps1; \
powershell -ExecutionPolicy Unrestricted -File ./install-powershell.ps1 -AddToPath

RUN Invoke-WebRequest \
-Uri https://github.com/actions/runner/releases/download/v$env:RUNNER_VERSION/actions-runner-win-x64-$env:RUNNER_VERSION.zip \
-OutFile runner.zip; \
Expand-Archive -Path C:/runner.zip -DestinationPath C:/actions-runner; \
Remove-Item -Path C:\runner.zip; \
setx /M PATH $(${Env:PATH} + \";${Env:ProgramFiles}\Git\bin\")

ADD runner.ps1 C:/runner.ps1
CMD ["pwsh", "-ExecutionPolicy", "Unrestricted", "-File", ".\\runner.ps1"]
2 changes: 2 additions & 0 deletions runner/runner.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.\actions-runner\config.cmd --unattended --replace --url https://github.com/${env:RUNNER_REPO} --token $env:RUNNER_TOKEN --name $env:RUNNER_NAME --work $env:RUNNER_WORKDIR;
.\actions-runner\run.cmd;