{"id":17722662,"url":"https://github.com/christopherhx/megascaler","last_synced_at":"2025-03-31T13:25:12.379Z","repository":{"id":109928486,"uuid":"514055852","full_name":"ChristopherHX/megascaler","owner":"ChristopherHX","description":"WIP Autoscaler for self-hosted runners","archived":false,"fork":false,"pushed_at":"2022-11-05T12:42:54.000Z","size":69,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-03-05T03:25:21.636Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChristopherHX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-14T21:44:11.000Z","updated_at":"2022-07-14T21:47:00.000Z","dependencies_parsed_at":"2023-04-01T05:24:48.388Z","dependency_job_id":null,"html_url":"https://github.com/ChristopherHX/megascaler","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristopherHX%2Fmegascaler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristopherHX%2Fmegascaler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristopherHX%2Fmegascaler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChristopherHX%2Fmegascaler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChristopherHX","download_url":"https://codeload.github.com/ChristopherHX/megascaler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246473273,"owners_count":20783236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-25T15:39:07.016Z","updated_at":"2025-03-31T13:25:12.361Z","avatar_url":"https://github.com/ChristopherHX.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# megascaler\nWIP Autoscaler for self-hosted runners.\n\nThis program will communticate with GitHub to receive job requests and will delegate running the job to a worker program, while the worker program has no access to the runner / PAT tokens if it is spawned in an isolated environment.\n\nWorks with both the official https://github.com/actions/runner and the unofficial https://github.com/ChristopherHX/github-act-runner.\n\n## Known problems\n- you should avoid using multiple labels\n  - if you really want to use them always provide an entry for any possible configuration\n  - your jobs with more labels may wait longer for execution, due to other jobs taking away your runner\n  - might need to create runners with more labels than requested to minimize queue time\n- webhooks cannot always be delivered, need to add github api polling for reliability if waiting long\n\n## Goals\n- listen for `workflow_job` webhooks\n- create an inmemory runner with a PAT token\n- track job assignment, so you can control in which environment the job executes\n- cache runner registration token, valid for ca. 1 hour\n- cache runner registration jwt, very short lived you can still register ca. \u003e 1000 runners without extra rate limit cost\n- use both actions/runner and nektos/act worker\n- provide a script to allocate a target enviroment for a job\n- provide a script to execute the worker process on the target enviroment, by forwarding stdin\n\n## Extras for actions/runner\n- `${{ github.megascaler.jobid }}` is assigned to the rest api job id\n- `${{ github.megascaler.job_url }}` is assigned to the job html url\n- `${{ github.megascaler.run_url }}` is assigned to the workflow run html url\n- `${{ github.megascaler.labels }}` is assigned to an array of string with all labels from `runs-on` of the current instance\n- `${{ github.megascaler.variables }}` is assigned to the otherwise hidden system variables of Actions\n- `${{ github.megascaler.jobDisplayName }}` is assigned to the otherwise hidden job display name\n\n## Non representative Statistics\n- 68 of 81 jobs have received the wrong runner\n- average time between job start and webhook in_progress is between 1s and 60s\n\n## Getting started\n\ncreate a `config.yml`\n```yaml\nworker:                                             # list of worker to spawn if the label list has an exact match\n- labels:\n  - github-act-runner                               # labels to spawn the specfic worker, if this matches what you added to the `runs-on` key this program will spawn a worker\n  args:\n  - /workspaces/megascaler/runner/github-act-runner # Path to https://github.com/ChristopherHX/github-act-runner binary\n  - worker                                          # Execute in worker mode\n- labels:\n  - actions-runner                                  # labels to spawn the specfic worker, if this matches what you added to the `runs-on` key this program will spawn a worker\n  args:                                             # create a `/workspaces/megascaler/runner/.runner` textfile with content `{\"workFolder\": \"_work\"}`\n  - pwsh                                            # Path to https://github.com/powershell/powershell binary or add it to your `PATH` env variable\n  - actions-runner-worker.ps1                       # Get the file from https://github.com/ChristopherHX/github-act-runner/blob/main/compat/actions-runner-worker.ps1\n  - /workspaces/megascaler/runner/bin/Runner.Worker # Path to https://github.com/actions/runner binary\naddress: 0.0.0.0:9403                               # webhook listener to receive `workflow_job` events from GitHub\n# secret: mysecret                                  # validate the webhook signature to harden the webhook endpoint\npat: ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX       # GitHub Classic PAT with full `repo` scope\n```\n\nYou can also pipe the worker via the `args` list via ssh or other programs, it will connect to GitHub via http and communicates over stdin/stdout.\n\nrun\n```\ngo build\n./megascaler\n```\n\nor debug `main.go`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristopherhx%2Fmegascaler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristopherhx%2Fmegascaler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristopherhx%2Fmegascaler/lists"}