Skip to content

About

Run your GitHub Actions workflows on Hatchet

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

github-actions-operator

Deploy to Cloudflare

Run your GitHub Actions jobs in Hatchet backed by Sandboxes and Serverless Endpoints. Put runs-on: hatchet in a workflow and every job gets a fresh sandbox and a just-in-time GitHub runner. The control logic is a durable task on a Hatchet serverless endpoint deployed as a Cloudflare Worker.

How it works

  1. Your GitHub App sends a workflow_job webhook to a Hatchet incoming webhook.
  2. Hatchet turns the queued event into a run of github-actions-on-job on your Worker. For a job with the hatchet label it starts the github-actions-run-job durable task, tagged with the repo, workflow, job and run URL.
  3. The task mints a just-in-time runner config with an installation token of your App, creates a sandbox from the official actions/actions-runner image, starts dockerd, and starts run.sh --jitconfig.
  4. The task sleeps until GitHub sends the matching completed event, checking every few minutes that the runner is still alive, then deletes the sandbox.

GitHub keeps the logs and the status checks. Hatchet keeps a run per job with the sandbox turns as children. Filter the runs list by the github.repo or github.job metadata to find a job, and follow github.job_url on the run to its GitHub page.

This repository has an example GitHub Actions workflow that runs on the operator.

Prerequisites

  • A Hatchet Cloud tenant with Serverless and Sandboxes turned on under Settings > Labs Preview.

  • A sandbox provider added under Sandboxes. Archil is the only provider that runs an arbitrary OCI image. Use this config and change the region as needed.

    {"region":"aws-us-east-1","workdir":"/home/runner"}

    On Daytona, E2B or Freestyle build a snapshot from ghcr.io/actions/actions-runner:2.338.2 and set SANDBOX_TEMPLATE to its name.

  • Node 24, pnpm, and a Cloudflare account with wrangler login done.

Setup

1. Hatchet webhook

pnpm install
cp .dev.vars.example .dev.vars

Put your Hatchet token in .dev.vars and run the setup once. It creates the Hatchet webhook and prints the webhook URL and secret for the next step.

pnpm register

2. GitHub App

Create a GitHub App under your account or organization at Settings > Developer settings > GitHub Apps > New GitHub App.

  • Webhook. Active, with the URL and secret from step 1.
  • Repository permissions. Actions read-only and Administration read and write. Nothing else.
  • Subscribe to events. Workflow jobs. The checkbox appears once Actions is granted.
  • Where can this GitHub App be installed. Only on this account, unless others should install it too.
  • Leave Request user authorization (OAuth) during installation off. The App needs no callback URL.

Create it, note the App ID, generate a private key and download the .pem. Then install the App on the repositories that should run on Hatchet.

3. Deploy the Worker

Click the button above. Cloudflare copies this repository into your GitHub account, asks for the secrets listed in .dev.vars.example, and deploys the Worker. Generate HATCHET_SIGNING_SECRET with openssl rand -hex 32. Paste the private key as is, or with \n in place of line breaks.

Or deploy from the clone.

wrangler secret put HATCHET_CLIENT_TOKEN
wrangler secret put HATCHET_SIGNING_SECRET
wrangler secret put GITHUB_APP_ID
wrangler secret put GITHUB_APP_PRIVATE_KEY < app.private-key.pem
wrangler secret put SANDBOX_PROVIDER
pnpm deploy

4. Register the endpoint

Fill in HATCHET_SIGNING_SECRET in .dev.vars and run the setup again with the Worker URL. It adds the serverless endpoint and leaves the webhook alone.

pnpm register https://github-actions-operator.<you>.workers.dev

Then use the label in a workflow.

jobs:
  test:
    runs-on: hatchet
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - run: uname -a

Variables

Secrets are Worker secrets. The rest have defaults under [vars] in wrangler.toml and can be overridden there or as secrets.

Variable Meaning
HATCHET_CLIENT_TOKEN Your Hatchet API token.
HATCHET_SIGNING_SECRET 32+ characters. The endpoint's signing secret in Hatchet, set by pnpm register.
GITHUB_APP_ID The App ID from the App's settings page.
GITHUB_APP_PRIVATE_KEY The App's private key in PEM form.
RUNNER_LABEL Jobs whose labels do not include it are skipped. Default hatchet.
SANDBOX_TEMPLATE Image or provider snapshot for the sandbox. Default ghcr.io/actions/actions-runner:2.338.2.
SANDBOX_PROVIDER Provider name. Required when the tenant has more than one.
SANDBOX_VCPU, SANDBOX_MEMORY_MIB Sandbox size. Omit for the provider default.
JOB_TIMEOUT The sandbox is deleted after this even if GitHub never reports the job done. Default 6h.
KEEPALIVE_INTERVAL How often the task checks that the runner is still alive. Keep it under the provider's max idle TTL, which defaults to 15 minutes. Default 5m.

About

Run your GitHub Actions workflows on Hatchet

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages