Skip to content

Commit

Permalink
fix: add --preserve-env to start-runner.sh to enable RUNNER_ALLOW_RUN…
Browse files Browse the repository at this point in the history
…ASROOT (#1537)
  • Loading branch information
inhumantsar committed Dec 21, 2021
1 parent 111f54c commit 1cd9cd3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions modules/runners/templates/start-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,20 @@ if [ -z "$run_as" ]; then
run_as="ec2-user"
fi

if [[ "$run_as" == "root" ]]; then
export RUNNER_ALLOW_RUNASROOT=1
fi

echo "Configure GH Runner as user $run_as"
sudo -u "$run_as" -- ./config.sh --unattended --name "$instance_id" --work "_work" $${config}
sudo --preserve-env=RUNNER_ALLOW_RUNASROOT -u "$run_as" -- ./config.sh --unattended --name "$instance_id" --work "_work" $${config}

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

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

echo "Stopping cloudwatch service"
Expand Down

0 comments on commit 1cd9cd3

Please sign in to comment.