Skip to content

Commit

Permalink
Add Docker image for Github Actions runner
Browse files Browse the repository at this point in the history
This change adds configuration for a Docker image to be used as Github
Actions runner.
  • Loading branch information
fabianishere committed Feb 25, 2023
1 parent 0ffeef0 commit 7d28f8c
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
53 changes: 53 additions & 0 deletions runner/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM debian:bullseye

ARG GITHUB_RUNNER_VERSION="2.301.1"

ENV GITHUB_PAT ""
ENV GITHUB_OWNER "fabianishere"
ENV GITHUB_REPOSITORY "pve-edge-kernel"
ENV RUNNER_WORKDIR "_work"

RUN apt-get update \
&& apt-get install -y \
curl \
sudo \
git \
jq \
devscripts \
debhelper \
equivs \
asciidoc \
bc \
bison \
cpio \
dwarves \
flex \
kmod \
libdw-dev \
libelf-dev \
libiberty-dev \
libnuma-dev \
libslang2-dev \
libssl-dev \
lz4 \
quilt \
rsync \
xmlto \
zlib1g-dev \
zstd \
python3-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& useradd -m github \
&& usermod -aG sudo github \
&& echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER github
WORKDIR /home/github

RUN curl -Ls https://github.com/actions/runner/releases/download/v${GITHUB_RUNNER_VERSION}/actions-runner-linux-x64-${GITHUB_RUNNER_VERSION}.tar.gz | tar xz

COPY --chown=github:github entrypoint.sh ./entrypoint.sh
RUN sudo chmod u+x ./entrypoint.sh

ENTRYPOINT ["/home/github/entrypoint.sh"]
26 changes: 26 additions & 0 deletions runner/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
registration_url="https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPOSITORY}/actions/runners/registration-token"
echo "Requesting registration URL at '${registration_url}'"

payload=$(curl -sX POST -H "Authorization: token ${GITHUB_PAT}" ${registration_url})
export RUNNER_TOKEN=$(echo $payload | jq .token --raw-output)

./config.sh \
--name $(hostname) \
--token ${RUNNER_TOKEN} \
--url https://github.com/${GITHUB_OWNER}/${GITHUB_REPOSITORY} \
--work ${RUNNER_WORKDIR} \
--unattended \
--replace \
--label bullseye

remove() {
./config.sh remove --token "${RUNNER_TOKEN}"
}

trap 'remove; exit 130' INT
trap 'remove; exit 143' TERM

./run.sh "$*" &

wait $!

0 comments on commit 7d28f8c

Please sign in to comment.