-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
39 lines (32 loc) · 1 KB
/
entrypoint.sh
File metadata and controls
39 lines (32 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -e
# Check for required environment variables
if [ -z "$GITHUB_URL" ]; then
echo "Error: GITHUB_URL is required (e.g., https://github.com/owner/repo or https://github.com/owner)"
exit 1
fi
if [ -z "$GITHUB_TOKEN" ]; then
echo "Error: GITHUB_TOKEN is required (PAT or registration token)"
exit 1
fi
cd /home/runner/actions-runner
# Configure the runner
# Use --replace to allow re-registration if container restarts
# Note: Using --pat instead of --token due to GitHub Actions runner bug
# See: https://github.com/actions/runner/issues/1882
./config.sh \
--url "${GITHUB_URL}" \
--pat "${GITHUB_TOKEN}" \
--name "${RUNNER_NAME:-docker-runner}" \
--labels "${RUNNER_LABELS:-self-hosted,Linux,ARM64,amazonlinux}" \
--work "${RUNNER_WORKDIR:-_work}" \
--unattended \
--replace
# Cleanup function to remove runner on exit
cleanup() {
echo "Removing runner..."
./config.sh remove --pat "${GITHUB_TOKEN}" || true
}
trap cleanup EXIT
# Run the runner
./run.sh