Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 1cd9cd3

Browse files
authored
fix: add --preserve-env to start-runner.sh to enable RUNNER_ALLOW_RUNASROOT (#1537)
1 parent 111f54c commit 1cd9cd3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: modules/runners/templates/start-runner.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,20 @@ if [ -z "$run_as" ]; then
5454
run_as="ec2-user"
5555
fi
5656

57+
if [[ "$run_as" == "root" ]]; then
58+
export RUNNER_ALLOW_RUNASROOT=1
59+
fi
60+
5761
echo "Configure GH Runner as user $run_as"
58-
sudo -u "$run_as" -- ./config.sh --unattended --name "$instance_id" --work "_work" $${config}
62+
sudo --preserve-env=RUNNER_ALLOW_RUNASROOT -u "$run_as" -- ./config.sh --unattended --name "$instance_id" --work "_work" $${config}
5963

6064
## Start the runner
6165
echo "Starting runner after $(awk '{print int($1/3600)":"int(($1%3600)/60)":"int($1%60)}' /proc/uptime)"
6266
echo "Starting the runner as user $run_as"
6367

6468
if [[ $agent_mode = "ephemeral" ]]; then
6569
echo "Starting the runner in ephemeral mode"
66-
sudo -u "$run_as" -- ./run.sh
70+
sudo --preserve-env=RUNNER_ALLOW_RUNASROOT -u "$run_as" -- ./run.sh
6771
echo "Runner has finished"
6872

6973
echo "Stopping cloudwatch service"

0 commit comments

Comments
 (0)