mirror of
https://github.com/hanzoai/docker-github-actions-runner.git
synced 2026-09-30 21:42:55 +00:00
- Add the ability to specify a personal access token to use for calling the new Actions API for a runner token - Add `jq` and `docker-compose` to the `Dockerfile` - Update `README.md`
30 lines
953 B
Bash
30 lines
953 B
Bash
#!/bin/bash
|
|
|
|
export RUNNER_ALLOW_RUNASROOT=1
|
|
export PATH=$PATH:/actions-runner
|
|
|
|
_RUNNER_NAME=${RUNNER_NAME:-default}
|
|
_RUNNER_WORKDIR=${RUNNER_WORKDIR:-/_work}
|
|
|
|
if [[ -n "${ACCESS_TOKEN}" ]]; then
|
|
URI=https://api.github.com
|
|
API_VERSION=v3
|
|
API_HEADER="Accept: application/vnd.github.${API_VERSION}+json"
|
|
AUTH_HEADER="Authorization: token ${ACCESS_TOKEN}"
|
|
|
|
_PROTO="$(echo "${REPO_URL}" | grep :// | sed -e's,^\(.*://\).*,\1,g')"
|
|
_URL="$(echo "${REPO_URL/${_PROTO}/}")"
|
|
_PATH="$(echo "${_URL}" | grep / | cut -d/ -f2-)"
|
|
_ACCOUNT="$(echo "${_PATH}" | cut -d/ -f1)"
|
|
_REPO="$(echo "${_PATH}" | cut -d/ -f2)"
|
|
|
|
RUNNER_TOKEN="$(curl -XPOST -fsSL \
|
|
-H "${AUTH_HEADER}" \
|
|
-H "${API_HEADER}" \
|
|
"${URI}/repos/${_ACCOUNT}/${_REPO}/actions/runners/registration-token" \
|
|
| jq -r '.token')"
|
|
fi
|
|
|
|
./config.sh --url "${REPO_URL}" --token "${RUNNER_TOKEN}" --name "${_RUNNER_NAME}" --work "${_RUNNER_WORKDIR}"
|
|
./run.sh
|