Skip to content

Commit cf142cb

Browse files
committed
Merge branch 'main' into feature/docker-container
2 parents 88289a7 + 03f7189 commit cf142cb

6 files changed

Lines changed: 65 additions & 41 deletions

File tree

.github/workflows/tests.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,33 @@ jobs:
2626

2727
strategy:
2828
matrix:
29-
runner: [1,2,3,4,5]
29+
runner: [1,2,3]
3030
steps:
3131
- uses: actions/checkout@v4
3232

3333
- name: Debug
3434
run: |
35-
echo "Who am I: $(whoami)"
36-
echo "Hostname: $(hostname -f)"
37-
echo "Environment:"
38-
env
35+
echo "Who am I: $(whoami)@$(hostname -f)"
36+
echo "Where am I: $(pwd)"
37+
echo "Env:"
38+
env | grep GITHUB
3939
4040
- name: Help
4141
run: |
4242
echo "Hi from .github/workflows/tests.yml!"
43-
./github-runner --help
43+
./github-runner-installer --help
4444
4545
- name: Run
4646
run: |
47-
./github-runner \
47+
./github-runner-installer \
48+
--run \
49+
--name=${RUNNER_CONFIG_NAME} \
50+
--config-sh-options=--ephemeral
51+
52+
- name: Run again
53+
run: |
54+
./github-runner-installer \
55+
--run \
4856
--name=${RUNNER_CONFIG_NAME} \
4957
--config-sh-options=--ephemeral
5058
@@ -53,7 +61,7 @@ jobs:
5361
runs-on: "jonpugh@github-runner.${{ github.run_id }}"
5462
strategy:
5563
matrix:
56-
runner: [1,2,3,4,5]
64+
runner: [1,2,3,4,5,6]
5765
steps:
5866
- uses: actions/checkout@v4
5967

@@ -63,3 +71,7 @@ jobs:
6371
echo "Hostname: $(hostname -f)"
6472
echo "Environment:"
6573
env
74+
75+
- name: A second task
76+
run: |
77+
echo "Confirmed."

Dockerfile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@ RUN yum install -y \
1010
jq
1111

1212
# This codebase. The runner wrapper script.
13-
COPY ./ /github-runner
14-
WORKDIR /github-runner
13+
COPY ./ /github-runner-installer
14+
WORKDIR /github-runner-installer
1515
RUN chown runner:runner . -R
1616

1717
# GitHub Runner code.
1818
# Install runner to a path that won't ever be in a volume.
1919
ENV RUNNER_PATH /usr/share/github-runner
20-
# We are installing as root then switching back because we need to use the install-dependencies script.
21-
RUN ./github-runner --no-run --no-config --runner-path=${RUNNER_PATH}
22-
RUN ${RUNNER_PATH}/bin/installdependencies.sh
23-
RUN chown runner:runner ${RUNNER_PATH} -R
2420

21+
# Install Dependencies
22+
RUN curl https://raw.githubusercontent.com/actions/runner/refs/tags/v2.326.0/src/Misc/layoutbin/installdependencies.sh -o install-dependencies \
23+
&& bash install-dependencies
24+
25+
# Run github-runner-installer script.
26+
#RUN ./github-runner-installer --no-run --no-config --runner-path=${RUNNER_PATH}
27+
28+
# Change runner ownership & Switch user.
29+
# RUN chown runner:runner ${RUNNER_PATH} -R
2530
USER runner

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# github-runner
1+
# github-runner-installer
22
A single script to install, configure, launch, and cleanup GitHub runners.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
],
1212
"require": {},
1313
"bin": [
14-
"github-runner"
14+
"github-runner-installer"
1515
]
1616
}

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ services:
77
image: jonpugh/github-runner
88
hostname: localhost
99
volumes:
10-
- ./:/github-runner
10+
- ./:/github-runner-installer
1111
environment:
1212
GITHUB_TOKEN: ${GITHUB_TOKEN}
13-
GITHUB_REPOSITORY: jonpugh/github-runner
13+
GITHUB_REPOSITORY: operations-project/github-runner-installer
1414
RUNNER_CONFIG_LABELS: ${RUNNER_CONFIG_LABELS:-runner@localhost}
1515
entrypoint: ./docker-entrypoint
16-
command: ./github-runner
16+
command: ./github-runner-installer
1717
build: ./
1818

1919
# Give the containers more time to shutdown before being cancelled.

github-runner renamed to github-runner-installer

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ start() {
99

1010

1111
if [[ -n $RUNNER_CONFIG ]]; then
12-
say Launching runner with run.sh ...
12+
say Configuring runner with config.sh ...
1313
line
1414
configure
1515
else
@@ -30,8 +30,8 @@ start() {
3030
wait $RUNNER_PID
3131

3232
else
33-
say Launching runner with run.sh ... SKIPPED.
34-
say Exiting github-runner.
33+
say Skipped running due to --no-run option.
34+
say Exiting github-runner-installer.
3535
fi
3636

3737
}
@@ -52,6 +52,9 @@ info() {
5252
say "Repo: ${RUNNER_URL_REPO}"
5353
say "Labels: ${RUNNER_CONFIG_LABELS}"
5454
say "Status: ${RUNNER_URL_RUNNERS}"
55+
line
56+
say "Run: ${RUNNER_RUN:-no}"
57+
5558
}
5659
usage() {
5760
say GitHub Runner Script
@@ -61,7 +64,7 @@ usage() {
6164
echo "--repo (GITHUB_REPOSITORY) The GitHub repo to install the runner on. (eg. owner/repo)"
6265
echo "--name (RUNNER_CONFIG_NAME) The name to give the runner. (Default: $(whoami)@$(hostname -f))"
6366
echo "--labels (RUNNER_CONFIG_LABELS) A list of labels to assign to the runner. (Default: $(whoami)@$(hostname -f))"
64-
echo "--no-run (RUNNER_RUN) If empty, don't run."
67+
echo "--run (RUNNER_RUN) Launch the runner with run.sh after installing."
6568
echo "--config-sh-options (RUNNER_CONFIG_OPTIONS) Pass options to the github runner config.sh command."
6669
}
6770
verify() {
@@ -76,9 +79,9 @@ verify() {
7679
# Detect path to this script.
7780
# @TODO: Rename RUNNER_SCRIPT_ to reduce confusion with github runner CLI
7881
if [[ -z "$COMPOSER_RUNTIME_BIN_DIR" ]]; then
79-
RUNNER_SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/github-runner"
82+
RUNNER_SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/github-runner-installer"
8083
else
81-
RUNNER_SCRIPT_PATH="$COMPOSER_RUNTIME_BIN_DIR/github-runner"
84+
RUNNER_SCRIPT_PATH="$COMPOSER_RUNTIME_BIN_DIR/github-runner-installer"
8285
fi
8386
if [[ ! -f "${RUNNER_SCRIPT_PATH}" ]]; then
8487
say "Path detection failed."
@@ -90,11 +93,11 @@ verify() {
9093
# Defaults. If ENV vars exist, use them. If not, use these values.
9194
RUNNER_PATH=${RUNNER_PATH:-"runner"}
9295
RUNNER_CONFIG_NAME=${RUNNER_CONFIG_NAME:-$(whoami)@$(hostname -f)}
93-
RUNNER_CONFIG_LABELS=${RUNNER_CONFIG_LABELS:-"jonpugh/github-runner"}
96+
RUNNER_CONFIG_LABELS=${RUNNER_CONFIG_LABELS:-"operations-project/github-runner-installer"}
9497
RUNNER_CONFIG_OPTIONS=${RUNNER_CONFIG_OPTIONS:-""}
9598

9699
# Whether to run the runner
97-
RUNNER_RUN=${RUNNER_RUN:-"yes"}
100+
RUNNER_RUN=${RUNNER_RUN:-""}
98101
RUNNER_CONFIG=${RUNNER_CONFIG:-"yes"}
99102

100103
# Command line Options
@@ -132,8 +135,8 @@ verify() {
132135
RUNNER_CONFIG_OPTIONS="${1#*=}"
133136
;;
134137

135-
--no-run)
136-
RUNNER_RUN=""
138+
--run)
139+
RUNNER_RUN="yes"
137140
;;
138141

139142
--no-config)
@@ -229,6 +232,20 @@ currentArchitecture() {
229232
;;
230233
esac
231234
}
235+
currentArchitecture() {
236+
architecture=$(uname -m)
237+
case "$architecture" in
238+
x86_64)
239+
echo "x64"
240+
;;
241+
aarch64 | arm64)
242+
echo "arm64"
243+
;;
244+
*)
245+
exit 1
246+
;;
247+
esac
248+
}
232249
latestVersion() {
233250
RUNNER_CLI_REPO=actions/runner
234251
curl -s -L \
@@ -275,15 +292,7 @@ download() {
275292
configure() {
276293
line
277294
say Configuring GitHub runner...
278-
say Removing existing runner...
279-
280-
# Remove
281-
# @TODO: If runner has a job, wait for it to complete.
282295
cd $RUNNER_FOLDER
283-
./config.sh remove --token ${RUNNER_CONFIG_TOKEN} || say "config remove didn't work."
284-
285-
line
286-
say Configuring new runner...
287296

288297
# Configure
289298
CMD="./config.sh \
@@ -299,11 +308,9 @@ configure() {
299308
say $CMD
300309
line
301310

302-
$CMD
311+
$CMD && say GitHub runner configured! || say GitHub Runner Config failed. Moving on...
303312

304313
line
305-
say GitHub runner configured:
306-
info
307314

308315
}
309316

@@ -329,7 +336,7 @@ cancel() {
329336
exit 1
330337
}
331338
say() {
332-
echo " github-runner | ${*}"
339+
echo " github-runner-installer | ${*}"
333340
}
334341
line() {
335342
CHARACTER="${CHARACTER:--}"

0 commit comments

Comments
 (0)