Skip to content

Commit

Permalink
Update registration token handling in start.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
collinmcneese committed May 11, 2024
1 parent 8f9d82c commit 5859afb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 12 deletions.
48 changes: 40 additions & 8 deletions docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,51 @@ cd /home/docker/actions-runner
if [[ -n ${GHRUNNER_GITHUB_BASE_URL} ]]; then
echo "Using GHES endpoint: ${GHRUNNER_GITHUB_BASE_URL}"
if [[ -n ${GHRUNNER_REPOSITORY} ]]; then
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" ${GHRUNNER_GITHUB_BASE_URL}/api/v3/repos/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}/actions/runners/registration-token | jq .token --raw-output)
./config.sh --url "${GHRUNNER_GITHUB_BASE_URL}/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}" --token "${REG_TOKEN}" --unattended --labels "${GHRUNNER_LABELS}" --ephemeral
if [[ -n ${GHRUNNER_REG_TOKEN} ]]; then
REG_TOKEN=${GHRUNNER_REG_TOKEN}
else
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" ${GHRUNNER_GITHUB_BASE_URL}/api/v3/repos/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}/actions/runners/registration-token | jq .token --raw-output)
fi
./config.sh --url "${GHRUNNER_GITHUB_BASE_URL}/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}" \
--token "${REG_TOKEN}" \
--unattended \
--labels "${GHRUNNER_LABELS}" \
--ephemeral ${GHRUNNER_RUNNER_GROUP:+--runnergroup "${GHRUNNER_RUNNER_GROUP}"}
else
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" ${GHRUNNER_GITHUB_BASE_URL}/api/v3/orgs/${GHRUNNER_ORGANIZATION}/actions/runners/registration-token | jq .token --raw-output)
./config.sh --url "${GHRUNNER_GITHUB_BASE_URL}/${GHRUNNER_ORGANIZATION}" --token "${REG_TOKEN}" --unattended --labels "${GHRUNNER_LABELS}" --ephemeral
if [[ -n ${GHRUNNER_REG_TOKEN} ]]; then
REG_TOKEN=${GHRUNNER_REG_TOKEN}
else
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" ${GHRUNNER_GITHUB_BASE_URL}/api/v3/orgs/${GHRUNNER_ORGANIZATION}/actions/runners/registration-token | jq .token --raw-output)
fi
./config.sh --url "${GHRUNNER_GITHUB_BASE_URL}/${GHRUNNER_ORGANIZATION}" \
--token "${REG_TOKEN}" \
--unattended \
--labels "${GHRUNNER_LABELS}" \
--ephemeral ${GHRUNNER_RUNNER_GROUP:+--runnergroup "${GHRUNNER_RUNNER_GROUP}"}
fi
else # Register with the GitHub endpoint
if [[ -n ${GHRUNNER_REPOSITORY} ]]; then
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" https://api.github.com/repos/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}/actions/runners/registration-token | jq .token --raw-output)
./config.sh --url "https://github.com/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}" --token "${REG_TOKEN}" --unattended --labels "${GHRUNNER_LABELS}" --ephemeral
if [[ -n ${GHRUNNER_REG_TOKEN} ]]; then
REG_TOKEN=${GHRUNNER_REG_TOKEN}
else
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" https://api.github.com/repos/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}/actions/runners/registration-token | jq .token --raw-output)
fi
./config.sh --url "https://github.com/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}" \
--token "${REG_TOKEN}" \
--unattended \
--labels "${GHRUNNER_LABELS}" \
--ephemeral ${GHRUNNER_RUNNER_GROUP:+--runnergroup "${GHRUNNER_RUNNER_GROUP}"}
else
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" https://api.github.com/orgs/${GHRUNNER_ORGANIZATION}/actions/runners/registration-token | jq .token --raw-output)
./config.sh --url "https://github.com/${GHRUNNER_ORGANIZATION}" --token "${REG_TOKEN}" --unattended --labels "${GHRUNNER_LABELS}" --ephemeral
if [[ -n ${GHRUNNER_REG_TOKEN} ]]; then
REG_TOKEN=${GHRUNNER_REG_TOKEN}
else
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" https://api.github.com/orgs/${GHRUNNER_ORGANIZATION}/actions/runners/registration-token | jq .token --raw-output)
fi
./config.sh --url "https://github.com/${GHRUNNER_ORGANIZATION}" \
--token "${REG_TOKEN}" \
--unattended \
--labels "${GHRUNNER_LABELS}" \
--ephemeral ${GHRUNNER_RUNNER_GROUP:+--runnergroup "${GHRUNNER_RUNNER_GROUP}"}
fi
fi

Expand Down
24 changes: 20 additions & 4 deletions runner-no-dind/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ if [[ -n ${GHRUNNER_GITHUB_BASE_URL} ]]; then
else
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" ${GHRUNNER_GITHUB_BASE_URL}/api/v3/repos/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}/actions/runners/registration-token | jq .token --raw-output)
fi
./config.sh --url "${GHRUNNER_GITHUB_BASE_URL}/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}" --token "${REG_TOKEN}" --unattended --labels "${GHRUNNER_LABELS}" --ephemeral
./config.sh --url "${GHRUNNER_GITHUB_BASE_URL}/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}" \
--token "${REG_TOKEN}" \
--unattended \
--labels "${GHRUNNER_LABELS}" \
--ephemeral ${GHRUNNER_RUNNER_GROUP:+--runnergroup "${GHRUNNER_RUNNER_GROUP}"}
else
if [[ -n ${GHRUNNER_REG_TOKEN} ]]; then
REG_TOKEN=${GHRUNNER_REG_TOKEN}
else
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" ${GHRUNNER_GITHUB_BASE_URL}/api/v3/orgs/${GHRUNNER_ORGANIZATION}/actions/runners/registration-token | jq .token --raw-output)
fi
./config.sh --url "${GHRUNNER_GITHUB_BASE_URL}/${GHRUNNER_ORGANIZATION}" --token "${REG_TOKEN}" --unattended --labels "${GHRUNNER_LABELS}" --ephemeral
./config.sh --url "${GHRUNNER_GITHUB_BASE_URL}/${GHRUNNER_ORGANIZATION}" \
--token "${REG_TOKEN}" \
--unattended \
--labels "${GHRUNNER_LABELS}" \
--ephemeral ${GHRUNNER_RUNNER_GROUP:+--runnergroup "${GHRUNNER_RUNNER_GROUP}"}
fi
else # Register with the GitHub endpoint
if [[ -n ${GHRUNNER_REPOSITORY} ]]; then
Expand All @@ -27,14 +35,22 @@ else # Register with the GitHub endpoint
else
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" https://api.github.com/repos/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}/actions/runners/registration-token | jq .token --raw-output)
fi
./config.sh --url "https://github.com/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}" --token "${REG_TOKEN}" --unattended --labels "${GHRUNNER_LABELS}" --ephemeral
./config.sh --url "https://github.com/${GHRUNNER_ORGANIZATION}/${GHRUNNER_REPOSITORY}" \
--token "${REG_TOKEN}" \
--unattended \
--labels "${GHRUNNER_LABELS}" \
--ephemeral ${GHRUNNER_RUNNER_GROUP:+--runnergroup "${GHRUNNER_RUNNER_GROUP}"}
else
if [[ -n ${GHRUNNER_REG_TOKEN} ]]; then
REG_TOKEN=${GHRUNNER_REG_TOKEN}
else
REG_TOKEN=$(curl -sX POST -H "Authorization: token ${GHRUNNER_ACCESS_TOKEN}" https://api.github.com/orgs/${GHRUNNER_ORGANIZATION}/actions/runners/registration-token | jq .token --raw-output)
fi
./config.sh --url "https://github.com/${GHRUNNER_ORGANIZATION}" --token "${REG_TOKEN}" --unattended --labels "${GHRUNNER_LABELS}" --ephemeral
./config.sh --url "https://github.com/${GHRUNNER_ORGANIZATION}" \
--token "${REG_TOKEN}" \
--unattended \
--labels "${GHRUNNER_LABELS}" \
--ephemeral ${GHRUNNER_RUNNER_GROUP:+--runnergroup "${GHRUNNER_RUNNER_GROUP}"}
fi
fi

Expand Down

0 comments on commit 5859afb

Please sign in to comment.