From bad55698f09abc0bd6bfce7e354f98fb40745299 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 10 Jul 2025 11:18:30 -0400 Subject: [PATCH 1/8] Don't remove the runner, we are replacing it. --- github-runner-installer | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/github-runner-installer b/github-runner-installer index 16203eb..58bd32d 100755 --- a/github-runner-installer +++ b/github-runner-installer @@ -283,8 +283,13 @@ configure() { # Remove # @TODO: If runner has a job, wait for it to complete. cd $RUNNER_FOLDER - echo ./config.sh remove --token ${RUNNER_CONFIG_TOKEN} - ./config.sh remove --token ${RUNNER_CONFIG_TOKEN} || say "config remove didn't work." + + # @TODO: determine if config remove is needed. Seems like --replace should work? + # echo ./config.sh remove --token ${RUNNER_CONFIG_TOKEN} + # config.sh remove can fail because: + # 1. the service is still installed. + # 2. TBD. + # ./config.sh remove --token ${RUNNER_CONFIG_TOKEN} || say "config remove didn't work." rm -rf .credentials .runner line From 1e87d2a528fe5da843660e8f75232a2e00209295 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 10 Jul 2025 11:26:33 -0400 Subject: [PATCH 2/8] Save some cycles. --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7f4f48b..5d86a6d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,7 +26,7 @@ jobs: strategy: matrix: - runner: [1,2,3,4,5] + runner: [1,2,3] steps: - uses: actions/checkout@v4 @@ -54,7 +54,7 @@ jobs: runs-on: "jonpugh@github-runner.${{ github.run_id }}" strategy: matrix: - runner: [1,2,3,4,5] + runner: [1,2,3] steps: - uses: actions/checkout@v4 From 8049f3a3e86b9ace08dbe5c413e7f0e89ecd980d Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 10 Jul 2025 11:29:01 -0400 Subject: [PATCH 3/8] Better debug --- .github/workflows/tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5d86a6d..c46f4c4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,10 +32,10 @@ jobs: - name: Debug run: | - echo "Who am I: $(whoami)" - echo "Hostname: $(hostname -f)" - echo "Environment:" - env + echo "Who am I: $(whoami)@$(hostname -f)" + echo "Where am I: $(whoami)" + echo "Env:" + env | grep GITHUB - name: Help run: | From ece1979a414190961727c2892d747872610eeef9 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 10 Jul 2025 11:30:13 -0400 Subject: [PATCH 4/8] Better debug --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c46f4c4..9f283f2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,7 +33,7 @@ jobs: - name: Debug run: | echo "Who am I: $(whoami)@$(hostname -f)" - echo "Where am I: $(whoami)" + echo "Where am I: $(pwd)" echo "Env:" env | grep GITHUB From 90e8d82ac96eee8ddd6e77f32409a84c392d855e Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 10 Jul 2025 11:38:03 -0400 Subject: [PATCH 5/8] Remove removal. --- github-runner-installer | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/github-runner-installer b/github-runner-installer index 58bd32d..787d63f 100755 --- a/github-runner-installer +++ b/github-runner-installer @@ -278,22 +278,7 @@ download() { configure() { line say Configuring GitHub runner... - say Removing existing runner... - - # Remove - # @TODO: If runner has a job, wait for it to complete. cd $RUNNER_FOLDER - - # @TODO: determine if config remove is needed. Seems like --replace should work? - # echo ./config.sh remove --token ${RUNNER_CONFIG_TOKEN} - # config.sh remove can fail because: - # 1. the service is still installed. - # 2. TBD. - # ./config.sh remove --token ${RUNNER_CONFIG_TOKEN} || say "config remove didn't work." - - rm -rf .credentials .runner - line - say Configuring new runner... # Configure CMD="./config.sh \ From bfcc9786a55b15a6b231b36d0ba834addd86f9c2 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 10 Jul 2025 12:56:02 -0400 Subject: [PATCH 6/8] Fix name and install deps. --- Dockerfile | 13 +++++++++---- docker-compose.yml | 2 +- github-runner-installer | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 312d604..d584593 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,9 +17,14 @@ RUN chown runner:runner . -R # GitHub Runner code. # Install runner to a path that won't ever be in a volume. ENV RUNNER_PATH /usr/share/github-runner -# We are installing as root then switching back because we need to use the install-dependencies script. -RUN ./github-runner-installer --no-run --no-config --runner-path=${RUNNER_PATH} -RUN ${RUNNER_PATH}/bin/installdependencies.sh -RUN chown runner:runner ${RUNNER_PATH} -R +# Install Dependencies +RUN curl https://raw.githubusercontent.com/actions/runner/refs/tags/v2.326.0/src/Misc/layoutbin/installdependencies.sh -o install-dependencies \ + && bash install-dependencies + +# Run github-runner-installer script. +#RUN ./github-runner-installer --no-run --no-config --runner-path=${RUNNER_PATH} + +# Change runner ownership & Switch user. +# RUN chown runner:runner ${RUNNER_PATH} -R USER runner diff --git a/docker-compose.yml b/docker-compose.yml index c97185c..8585659 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - ./:/github-runner-installer environment: GITHUB_TOKEN: ${GITHUB_TOKEN} - GITHUB_REPOSITORY: jonpugh/github-runner + GITHUB_REPOSITORY: operations-project/github-runner-installer RUNNER_CONFIG_LABELS: ${RUNNER_CONFIG_LABELS:-runner@localhost} entrypoint: ./docker-entrypoint command: ./github-runner-installer diff --git a/github-runner-installer b/github-runner-installer index 787d63f..f5208e6 100755 --- a/github-runner-installer +++ b/github-runner-installer @@ -93,7 +93,7 @@ verify() { # Defaults. If ENV vars exist, use them. If not, use these values. RUNNER_PATH=${RUNNER_PATH:-"runner"} RUNNER_CONFIG_NAME=${RUNNER_CONFIG_NAME:-$(whoami)@$(hostname -f)} - RUNNER_CONFIG_LABELS=${RUNNER_CONFIG_LABELS:-"jonpugh/github-runner-installer"} + RUNNER_CONFIG_LABELS=${RUNNER_CONFIG_LABELS:-"operations-project/github-runner-installer"} RUNNER_CONFIG_OPTIONS=${RUNNER_CONFIG_OPTIONS:-""} # Whether to run the runner From 2bfe36e4a0585811dbc50cd405570eec55793b9f Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 10 Jul 2025 12:57:29 -0400 Subject: [PATCH 7/8] Run runner again to be sure it is idempotent. --- .github/workflows/tests.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9f283f2..ac8afd0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,6 +49,13 @@ jobs: --name=${RUNNER_CONFIG_NAME} \ --config-sh-options=--ephemeral + - name: Run again + run: | + ./github-runner-installer \ + --run \ + --name=${RUNNER_CONFIG_NAME} \ + --config-sh-options=--ephemeral + run: name: Run Tasks runs-on: "jonpugh@github-runner.${{ github.run_id }}" @@ -64,3 +71,7 @@ jobs: echo "Hostname: $(hostname -f)" echo "Environment:" env + + - name: A second task + run: | + echo "Confirmed." From e0dd9aae2b296b1befb7e63911e20c0cf0c3b425 Mon Sep 17 00:00:00 2001 From: Jon Pugh Date: Thu, 10 Jul 2025 12:58:25 -0400 Subject: [PATCH 8/8] Add more tasks so the reset is tested. --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac8afd0..46df0a7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -61,7 +61,7 @@ jobs: runs-on: "jonpugh@github-runner.${{ github.run_id }}" strategy: matrix: - runner: [1,2,3] + runner: [1,2,3,4,5,6] steps: - uses: actions/checkout@v4