-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·63 lines (50 loc) · 1.67 KB
/
entrypoint.sh
File metadata and controls
executable file
·63 lines (50 loc) · 1.67 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -e
# Check if required environment variables are set
if [ -z "$GITHUB_URL" ]; then
echo "Error: GITHUB_URL environment variable is required"
exit 1
fi
if [ -z "$GITHUB_TOKEN" ]; then
echo "Error: GITHUB_TOKEN environment variable is required"
echo "Get this token from GitHub Organization Settings -> Actions -> Runners -> Add runner"
exit 1
fi
# Set default runner name if not provided
RUNNER_NAME=${RUNNER_NAME:-"docker-runner-$(hostname)"}
# Set default work directory
RUNNER_WORKDIR=${RUNNER_WORKDIR:-"_work"}
# Set default labels for organization runner
RUNNER_LABELS=${RUNNER_LABELS:-"docker,self-hosted,linux,org"}
# Configure the runner (following GitHub's official steps)
echo "Configuring GitHub Actions Organization Runner..."
echo "URL: $GITHUB_URL"
echo "Runner Name: $RUNNER_NAME"
echo "Labels: $RUNNER_LABELS"
# Remove any existing runner configuration
if [ -f ".runner" ]; then
echo "Removing existing runner configuration..."
./config.sh remove --token "$GITHUB_TOKEN" || true
fi
# Create the runner and start the configuration experience (GitHub official step)
./config.sh \
--url "$GITHUB_URL" \
--token "$GITHUB_TOKEN" \
--name "$RUNNER_NAME" \
--work "$RUNNER_WORKDIR" \
--labels "$RUNNER_LABELS" \
--unattended \
--replace
# Function to handle graceful shutdown
cleanup() {
echo "Received shutdown signal. Removing runner..."
./config.sh remove --token "$GITHUB_TOKEN"
exit 0
}
# Set up signal handlers for graceful shutdown
trap cleanup SIGTERM SIGINT
# Last step, run it! (GitHub official step)
echo "Starting GitHub Actions Runner..."
./run.sh &
# Wait for the background process
wait $!