Skip to content

Commit

Permalink
Generate an instance ID for default runner name
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Sep 1, 2024
1 parent b15e7b2 commit 9daa458
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
run: go version
shell: bash
- name: Verify 'node'
run: |
node --version
npm --version
run: node --version
shell: bash
- name: Verify 'npm'
run: npm --version
shell: bash
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
version: '0.0.1'

services:
runner:
image: runner:latest
Expand Down
18 changes: 11 additions & 7 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ else
echo "Unknown OS: $(uname)"
fi

DEFAULT_LABEL="$os_name-$architecture"
RUNNER_SUFFIX="$(head -c 20 /dev/urandom | tr -dc 'a-z0-9' | fold -w 5 | head -n 1)"
DEFAULT_RUNNER_NAME="docker-node-${RUNNER_SUFFIX}"
instance_id() {
# Use randomly generated instance IDs (AWS format) as default runner names
letters=$(tr -dc '[:lower:]' < /dev/urandom | head -c 4)
digits=$(tr -dc '0-9' < /dev/urandom | head -c 12)
eid=$(echo "$letters$digits" | fold -w1 | shuf | tr -d '\n')
echo "0$eid"
}

# Env vars (docker-compose.yml)
RUNNER_NAME="${RUNNER_NAME:-$DEFAULT_RUNNER_NAME}"
RUNNER_GROUP="${RUNNER_GROUP:-default}"
WORK_DIR="${WORK_DIR:-_work}"
LABELS="${LABELS:-$DEFAULT_LABEL}"
RUNNER_NAME="${RUNNER_NAME:-"i-$(instance_id)"}"
RUNNER_GROUP="${RUNNER_GROUP:-"default"}"
WORK_DIR="${WORK_DIR:-"_work"}"
LABELS="${LABELS:-"docker-node,$os_name-$architecture"}"

repo_level_runner() {
# https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-registration-token-for-a-repository
Expand Down

0 comments on commit 9daa458

Please sign in to comment.