2.2 KiB · text 5af55d9
defmodule Mix.Tasks.Gitgud.Runner.Bootstrap do
@shortdoc "Print the commands needed to register a forgejo-runner against this instance."
@moduledoc """
mix gitgud.runner.bootstrap
Confirms the local instance is configured to accept runner
registrations and prints the exact `forgejo-runner` command line to
register against it.
Download forgejo-runner from
https://code.forgejo.org/forgejo/runner/releases.
Set `GITGUD_RUNNER_REG_TOKEN` (or configure
`config :git_gud, GitGud.Workflows.Runners, registration_token: ...`)
before running. Use a strong random value in production.
"""
use Mix.Task
@impl Mix.Task
def run(_argv) do
Mix.Task.run("app.start")
case GitGud.Workflows.Runners.registration_token() do
nil ->
Mix.shell().error("""
No registration token configured. Set one of:
* GITGUD_RUNNER_REG_TOKEN environment variable
* config :git_gud, GitGud.Workflows.Runners,
registration_token: "some-secret"
""")
System.halt(1)
token ->
url = GitGudWeb.Endpoint.url()
Mix.shell().info("""
── Forgejo runner setup ────────────────────────────────────────
1) Download the runner from
https://code.forgejo.org/forgejo/runner/releases
2) Register it against this instance:
forgejo-runner register \\
--instance #{url} \\
--token #{token} \\
--name my-runner \\
--labels ubuntu-latest
3) Start it:
forgejo-runner daemon
The runner will speak protobuf to:
#{url}/api/actions/_apis/runner.v1.PingService/Ping
#{url}/api/actions/_apis/runner.v1.RunnerService/Register
#{url}/api/actions/_apis/runner.v1.RunnerService/FetchTask
... and the rest of runner.v1.
Verify Ping responds 200:
curl -fsv -X POST \\
-H 'content-type: application/protobuf' \\
--data-binary '' \\
#{url}/api/actions/_apis/runner.v1.PingService/Ping
""")
end
end
end