feat: improve registoration for self-hosted runner

This commit is contained in:
Junya Morioka
2025-12-04 16:42:36 +09:00
parent 2bad59efd6
commit 3e30ef2270
4 changed files with 39 additions and 38 deletions
+8 -3
View File
@@ -90,14 +90,19 @@ Edit compose.yml file if you use repository folked from this repository.
services:
runner:
privileged: true
restart: always
env_file:
- .env
environment:
REPOSITORY_URL: https://github.com/[OWNER]/[REPOSITORY]
RUNNER_NAME: self-hosted-runner
RUNNER_GROUP: default
TARGET_ARCH: x64
build:
context: .
dockerfile: Dockerfile
args:
REPOSITORY_URL: [Target Repository URL]
GH_RUNNER_VERSION: 2.329.0
RUNNER_NAME: self-hosted-runner
RUNNER_GROUP: default
TARGET_ARCH: x64
```
+1 -30
View File
@@ -1,13 +1,7 @@
FROM ubuntu:24.04
ARG REPOSITORY_URL="https://github.com/user/repo"
ARG GH_RUNNER_VERSION="2.329.0"
ARG RUNNER_NAME="self-hosted-github-actions-runner"
ARG RUNNER_GROUP="default"
ARG RUNNER_LABELS="self-hosted,Linux"
ARG TARGET_ARCH="x64"
ARG PERSONAL_ACCESS_TOKEN=""
ARG REGISTRY_TOKEN=""
ENV DEBIAN_FRONTEND=noninteractive \
AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
@@ -65,27 +59,4 @@ WORKDIR /home/ubuntu
RUN curl -fsSL -o actions-runner.tar.gz -L "https://github.com/actions/runner/releases/download/v${GH_RUNNER_VERSION}/actions-runner-linux-${TARGET_ARCH}-${GH_RUNNER_VERSION}.tar.gz" \
&& tar xf actions-runner.tar.gz \
&& rm actions-runner.tar.gz \
&& sudo ./bin/installdependencies.sh \
&& if [ -n "$PERSONAL_ACCESS_TOKEN" ]; then \
./config.sh \
--unattended \
--url $REPOSITORY_URL \
--pat "$PERSONAL_ACCESS_TOKEN" \
--name $RUNNER_NAME \
--runnergroup $RUNNER_GROUP \
--labels "${RUNNER_LABELS},${TARGET_ARCH}" \
--work /home/ubuntu/actions-runner \
--replace; \
else \
./config.sh \
--unattended \
--url $REPOSITORY_URL \
--token "$REGISTRY_TOKEN" \
--name $RUNNER_NAME \
--runnergroup $RUNNER_GROUP \
--labels "${RUNNER_LABELS},${TARGET_ARCH}" \
--work /home/ubuntu/actions-runner \
--replace; \
fi
CMD ["./run.sh"]
&& sudo ./bin/installdependencies.sh
+5 -3
View File
@@ -4,12 +4,14 @@ services:
restart: always
env_file:
- .env
environment:
REPOSITORY_URL: https://github.com/mjun0812/flash-attention-prebuild-wheels
RUNNER_NAME: self-hosted-runner
RUNNER_GROUP: default
TARGET_ARCH: x64
build:
context: .
dockerfile: Dockerfile
args:
REPOSITORY_URL: https://github.com/mjun0812/flash-attention-prebuild-wheels
GH_RUNNER_VERSION: 2.329.0
RUNNER_NAME: self-hosted-runner
RUNNER_GROUP: default
TARGET_ARCH: x64
+25 -2
View File
@@ -1,7 +1,30 @@
#!/bin/bash
id
# Start docker daemon
sudo service docker start
exec "$@"
if [ -n "$PERSONAL_ACCESS_TOKEN" ]; then
echo "Using personal access token";
./config.sh \
--unattended \
--url $REPOSITORY_URL \
--pat "$PERSONAL_ACCESS_TOKEN" \
--name $RUNNER_NAME \
--runnergroup $RUNNER_GROUP \
--labels "${RUNNER_LABELS},${TARGET_ARCH}" \
--work /home/ubuntu/actions-runner \
--replace;
else
echo "Using registry token";
./config.sh \
--unattended \
--url $REPOSITORY_URL \
--token "$REGISTRY_TOKEN" \
--name $RUNNER_NAME \
--runnergroup $RUNNER_GROUP \
--labels "${RUNNER_LABELS},${TARGET_ARCH}" \
--work /home/ubuntu/actions-runner \
--replace;
fi
exec "./run.sh"