Context
In my .devcontainer.json
file I have postCreateCommand
and postStartCommand
jobs that point to startup.sh
script. My idempotent .startup.sh
script start github's self-hosted runner with nohup
process - that way the runner runs in background and don't stop it accidentally.
.devcontainer.json
"postCreateCommand": ".devcontainer/scripts/startup.sh",
"postStartCommand": ".devcontainer/scripts/startup.sh"
startup.sh
echo "Configure GitHub Runner"
./config.sh remove --token $SELF_HOSTED_RUNNER_TOKEN
./config.sh --url https://github.com/$GITHUB_REPOSITORY --unattended --token $SELF_HOSTED_RUNNER_TOKEN --name $RepositoryName --labels "self-hosted,Linux,X64,$RepositoryName"
echo "Start GitHub Runner"
nohup ./run.sh & > _diag/runner.log
Problem
When I create a new GitHub Codespace, my runners appear in Offline
mode. However, when I run my startup.sh
script from within my GitHub Codespace manually then it appears Idle
as expected.
Question
How to start GitHub self-hosted runner on devcontainer startup so, it's in Idle
state every time I start/restart my codespace?