ver 0.1
This commit is contained in:
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
# build-image.sh — build the custom-gitea-runner Docker image locally
|
||||
set -euo pipefail
|
||||
|
||||
IMAGE_NAME="${IMAGE_NAME:-custom-gitea-runner}"
|
||||
VERSION="${VERSION:-dev}"
|
||||
VCS_REF="$(git rev-parse --short HEAD 2>/dev/null || echo 'unknown')"
|
||||
BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
|
||||
echo "Building ${IMAGE_NAME}:${VERSION} ..."
|
||||
echo " VCS_REF : ${VCS_REF}"
|
||||
echo " BUILD_DATE : ${BUILD_DATE}"
|
||||
|
||||
docker build \
|
||||
--build-arg "VERSION=${VERSION}" \
|
||||
--build-arg "VCS_REF=${VCS_REF}" \
|
||||
--build-arg "BUILD_DATE=${BUILD_DATE}" \
|
||||
--tag "${IMAGE_NAME}:${VERSION}" \
|
||||
--tag "${IMAGE_NAME}:latest" \
|
||||
--file docker/runner/Dockerfile \
|
||||
.
|
||||
|
||||
echo "Build complete: ${IMAGE_NAME}:${VERSION}"
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# deregister-runner.sh — remove a runner registration from Gitea via the API.
|
||||
#
|
||||
# act_runner has no "unregister" command, so deregistration is done through the
|
||||
# Gitea REST API. This requires an *API* token (not a registration token) with
|
||||
# admin rights, plus the runner id or name. Run this before retiring or renaming
|
||||
# a runner to keep the Gitea UI clean, then delete the local config to start fresh.
|
||||
#
|
||||
# Usage:
|
||||
# GITEA_INSTANCE_URL=https://git.example.com \
|
||||
# GITEA_API_TOKEN=<admin-api-token> \
|
||||
# ./scripts/deregister-runner.sh <runner-name|runner-id>
|
||||
set -euo pipefail
|
||||
|
||||
: "${GITEA_INSTANCE_URL:?GITEA_INSTANCE_URL must be set (e.g. https://git.example.com)}"
|
||||
: "${GITEA_API_TOKEN:?GITEA_API_TOKEN must be set (an admin API token, not a registration token)}"
|
||||
|
||||
TARGET="${1:-}"
|
||||
if [ -z "${TARGET}" ]; then
|
||||
echo "[FATAL] Provide the runner name or id as the first argument." >&2
|
||||
echo "Usage: $0 <runner-name|runner-id>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
API="${GITEA_INSTANCE_URL%/}/api/v1"
|
||||
AUTH="Authorization: token ${GITEA_API_TOKEN}"
|
||||
|
||||
# Resolve a runner name to an id if a non-numeric target was given.
|
||||
if [[ "${TARGET}" =~ ^[0-9]+$ ]]; then
|
||||
RUNNER_ID="${TARGET}"
|
||||
else
|
||||
echo "Resolving runner id for name '${TARGET}' ..."
|
||||
RUNNER_ID="$(curl -fsS -H "${AUTH}" "${API}/admin/actions/runners" \
|
||||
| jq -r --arg n "${TARGET}" '.runners[] | select(.name==$n) | .id' | head -1)"
|
||||
if [ -z "${RUNNER_ID}" ]; then
|
||||
echo "[FATAL] No runner found with name '${TARGET}'." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Deregistering runner id ${RUNNER_ID} from ${GITEA_INSTANCE_URL} ..."
|
||||
http_code="$(curl -fsS -o /dev/null -w '%{http_code}' \
|
||||
-X DELETE -H "${AUTH}" "${API}/admin/actions/runners/${RUNNER_ID}")"
|
||||
|
||||
if [ "${http_code}" = "204" ]; then
|
||||
echo "Deregistration complete (runner id ${RUNNER_ID} removed)."
|
||||
echo "Remove the local config to start fresh: rm config/runner.yaml"
|
||||
else
|
||||
echo "[FATAL] Unexpected HTTP status ${http_code} from delete request." >&2
|
||||
exit 1
|
||||
fi
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
# publish-image.sh — tag and push the runner image to a registry
|
||||
set -euo pipefail
|
||||
|
||||
IMAGE_NAME="${IMAGE_NAME:-custom-gitea-runner}"
|
||||
REGISTRY="${REGISTRY:-registry.alwisp.com}"
|
||||
VERSION="${VERSION:-}"
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "[ERROR] VERSION must be set (e.g. VERSION=v0.1.0 ./scripts/publish-image.sh)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LOCAL_TAG="${IMAGE_NAME}:${VERSION}"
|
||||
REMOTE_TAG="${REGISTRY}/${IMAGE_NAME}:${VERSION}"
|
||||
REMOTE_LATEST="${REGISTRY}/${IMAGE_NAME}:latest"
|
||||
|
||||
echo "Tagging ${LOCAL_TAG} as ${REMOTE_TAG} ..."
|
||||
docker tag "${LOCAL_TAG}" "${REMOTE_TAG}"
|
||||
docker tag "${LOCAL_TAG}" "${REMOTE_LATEST}"
|
||||
|
||||
echo "Pushing ${REMOTE_TAG} ..."
|
||||
docker push "${REMOTE_TAG}"
|
||||
docker push "${REMOTE_LATEST}"
|
||||
|
||||
echo "Published: ${REMOTE_TAG}"
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# register-runner.sh — standalone registration helper (run outside container)
|
||||
# Useful for pre-generating config before first container start.
|
||||
set -euo pipefail
|
||||
|
||||
: "${GITEA_INSTANCE_URL:?GITEA_INSTANCE_URL must be set}"
|
||||
: "${GITEA_RUNNER_TOKEN:?GITEA_RUNNER_TOKEN must be set}"
|
||||
: "${GITEA_RUNNER_NAME:?GITEA_RUNNER_NAME must be set}"
|
||||
|
||||
RUNNER_CONFIG_PATH="${RUNNER_CONFIG_PATH:-./config/runner.yaml}"
|
||||
GITEA_RUNNER_LABELS="${GITEA_RUNNER_LABELS:-ubuntu-latest:docker://node:20-bullseye}"
|
||||
|
||||
echo "Registering runner: ${GITEA_RUNNER_NAME}"
|
||||
echo " Instance : ${GITEA_INSTANCE_URL}"
|
||||
echo " Config : ${RUNNER_CONFIG_PATH}"
|
||||
echo " Labels : ${GITEA_RUNNER_LABELS}"
|
||||
|
||||
mkdir -p "$(dirname "${RUNNER_CONFIG_PATH}")"
|
||||
|
||||
docker run --rm \
|
||||
-v "$(pwd)/config:/config" \
|
||||
-e GITEA_INSTANCE_URL="${GITEA_INSTANCE_URL}" \
|
||||
-e GITEA_RUNNER_TOKEN="${GITEA_RUNNER_TOKEN}" \
|
||||
-e GITEA_RUNNER_NAME="${GITEA_RUNNER_NAME}" \
|
||||
-e GITEA_RUNNER_LABELS="${GITEA_RUNNER_LABELS}" \
|
||||
-e RUNNER_CONFIG_PATH="/config/runner.yaml" \
|
||||
custom-gitea-runner:latest \
|
||||
act_runner register \
|
||||
--config /config/runner.yaml \
|
||||
--instance "${GITEA_INSTANCE_URL}" \
|
||||
--token "${GITEA_RUNNER_TOKEN}" \
|
||||
--name "${GITEA_RUNNER_NAME}" \
|
||||
--labels "${GITEA_RUNNER_LABELS}" \
|
||||
--no-interactive
|
||||
|
||||
echo "Registration complete. Config written to ${RUNNER_CONFIG_PATH}."
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# test-local-runner.sh — start a short-lived runner for local workflow testing
|
||||
# Requires a running Gitea instance and a valid registration token.
|
||||
set -euo pipefail
|
||||
|
||||
: "${GITEA_INSTANCE_URL:?GITEA_INSTANCE_URL must be set}"
|
||||
: "${GITEA_RUNNER_TOKEN:?GITEA_RUNNER_TOKEN must be set}"
|
||||
: "${GITEA_RUNNER_NAME:?GITEA_RUNNER_NAME must be set}"
|
||||
|
||||
IMAGE="${IMAGE:-custom-gitea-runner:latest}"
|
||||
CONFIG_DIR="$(mktemp -d /tmp/runner-test-config.XXXXXX)"
|
||||
WORK_DIR="$(mktemp -d /tmp/runner-test-work.XXXXXX)"
|
||||
|
||||
cleanup() {
|
||||
echo "Cleaning up temp dirs ..."
|
||||
rm -rf "$CONFIG_DIR" "$WORK_DIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "Starting local test runner ..."
|
||||
echo " Image : ${IMAGE}"
|
||||
echo " Config : ${CONFIG_DIR}"
|
||||
echo " Work : ${WORK_DIR}"
|
||||
|
||||
docker run --rm \
|
||||
-v "${CONFIG_DIR}:/config" \
|
||||
-v "${WORK_DIR}:/work" \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-e GITEA_INSTANCE_URL="${GITEA_INSTANCE_URL}" \
|
||||
-e GITEA_RUNNER_TOKEN="${GITEA_RUNNER_TOKEN}" \
|
||||
-e GITEA_RUNNER_NAME="${GITEA_RUNNER_NAME}" \
|
||||
-e GITEA_RUNNER_LABELS="${GITEA_RUNNER_LABELS:-ubuntu-latest:docker://node:20-bullseye}" \
|
||||
"${IMAGE}"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# verify-runtime.sh — validate the runner image tool chain without starting the daemon
|
||||
set -euo pipefail
|
||||
|
||||
IMAGE="${1:-custom-gitea-runner:latest}"
|
||||
|
||||
echo "Running smoke test against image: ${IMAGE}"
|
||||
|
||||
docker run --rm \
|
||||
--entrypoint /usr/local/bin/smoke-test.sh \
|
||||
"${IMAGE}"
|
||||
Reference in New Issue
Block a user