Github Actions is an event based scheduler that triggers based on user defined events. A commmon use for Github Actions is Continuous Integration / Continuous Development (CI/CD). But Github Actions can be configured to trigger off of any user defined event. This makes them very powerful for scheduling jobs.
In order to use Github Self-hosted Runners (GSR) you need three things:
- Github Hostname:
- https://github-hostname.com
- Github Organization
- https://github-hostname/settings/organizations
- Github Personal Access Token
- Settings > Developer Settings > Personal Access Tokens > Tokens (classic)
Note
A Github personal token is an identifier that lets Github Actions know who you are. Think of it as a userId. Make sure you allow all permissions.
You must download the code for a Git runner here. Note the version number because self-hosting may require versions within a certain range. Once you have identified the version you want, copy the download code into your container.
Rest API commands can be found here.
Pay special attention to the hostname
and the token
type. For standardized API calls see the Github CLI.
You must configure the gh.config
and gh.secret
files prior to building. The gh.config
point toward your hostname and organization while the gh.secret
is simply your Github Personal Access token.
# gh.config
export GH_HOSTNAME=<hostname>
export GH_ORG=<Github organization>
# gh.secret
ghp_XXXXXXXXXXXXXXXXXXXXXXXXX
Perform a build with the following commands:
cd containers
singularity build base.sif base.def
singularity build runner.sif runner.def
Finally run a test to verify that the runner is successful.
singularity run \
--userns \
--writable \
--app test \
runner.sif
If you need multiple Git runners operating on the system try using instances:
singularity instance start --userns --tmp-sandbox --writable runner.sif runner1
singularity instance start --userns --tmp-sandbox --writable runner.sif runner2
# Start runners
singularity run --app start_runner instance://runner1
singularity run --app start_runner instance://runner2
# List runners
singularity instance list
# Shell into runner
singularity shell instance://runner1
# Stop all runners
singularity run --app stop_runner instance://runner1
singularity run --app stop_runner instance://runner2