~/blog/seeloud-action
Inside seeloud-action: How Seeloud Runs Your CI Workflows
- ci
- docker
- github-actions
- bullmq
- architecture
Introduction
When you push a commit to a repository connected to Seeloud, a workflow defined in .github/workflows/*.yml springs to life: your code is cloned, a container spins up, and each step runs in order with its logs streaming to the dashboard in real time. The service that does all of that heavy lifting is action-worker — Seeloud's CI execution engine, internally called seeloud-action.
It is a Bun-based BullMQ worker that consumes jobs from the seeloud-actions queue, clones the repository at the exact commit SHA, pulls and boots a Docker container, then executes every workflow step inside it — supporting both run: shell commands and uses: Node.js actions like actions/checkout@v4. This post is a deep walk-through of exactly what happens between a git push and a green (or red) check mark.
run, exec, cp), and a high-level understanding of Redis job queues. This is a companion to Inside seeloudfn-runtime — the two services share the same BullMQ + internal-callback design language.System Architecture
The CI pipeline spans three moving parts: the API that receives GitHub webhooks, the Redis queue that decouples ingestion from execution, and the worker that actually runs the container. Understanding where action-worker sits is the right starting point.
The three services and their responsibilities:
- apps/api — Receives the GitHub webhook, fetches the workflow YAML at the pushed commit, parses it, matches the trigger (
push/pull_requestagainst the branch), creates theActionRun/ActionJob/ActionSteprows, and adds a job to the queue viaactionQueue.add(). - Redis / BullMQ — The
seeloud-actionsqueue is the hand-off point. It decouples the webhook handler (which must respond to GitHub fast) from execution (which can take minutes), and gives us back-pressure and retry semantics for free. - apps/action-worker — This service. Consumes invocation jobs, clones the repo, manages the Docker container lifecycle, runs each step, and reports logs and status back to the API's
/internalendpoints.
@repo/db) but funnels every log line and status change through authenticated HTTP callbacks to the API. This keeps the API as the single writer and the single source of truth for what the dashboard renders.The Job Lifecycle
Let us trace a single workflow run end-to-end, from the webhook to the final status patch.
Step 1 — API ingests the webhook and enqueues
When GitHub delivers a push or pull_request event, the API fetches every .github/workflows/*.yml file at that commit, parses each one, and checks whether its triggers match the event. For every matching workflow it creates an ActionRun, and for each job inside it an ActionJob plus its ActionStep rows — including an implicit setup step at number: -1 named "Set up job". It then enqueues the full payload:
interface ActionJobPayload {
runId: string
jobId: string
repoFullName: string // "owner/repo"
sha: string // exact commit to check out
ref: string // e.g. "refs/heads/main"
event: string // "push" | "pull_request"
runsOn: string // "ubuntu-latest" etc.
steps: WorkflowStep[] // parsed run: / uses: steps
env: Record<string, string> // workflow + job level env
secrets: Array<{ name: string; encryptedValue: string }>
encryptedGithubToken: string | null
actor: string // pusher login
}Note that secrets and the GitHub token travel through the queue encrypted. They are only decrypted inside the worker, in memory, at the moment they are needed.
Step 2 — Worker dequeues and marks RUNNING
The BullMQ worker pulls the job (up to WORKER_CONCURRENCY at once, default 2) and immediately patches the run and job to RUNNING with a start timestamp. It then decrypts the GitHub token and each secret using @repo/crypto's decryptValue. Decryption failures are logged and skipped rather than aborting the whole job — a single malformed secret should not take down the run.
Step 3 — Setup phase
All pre-step work is attributed to the setup step (number: -1) so its output shows up under "Set up job" in the UI, exactly like GitHub. This phase clones the repo, pulls the image, boots the container, and configures git. We cover it in detail in the next section.
Step 4 — The step loop
The worker iterates over the parsed steps, pairing each with its pre-created DB step row by index. For each step it evaluates the if: condition, interpolates ${{ }} expressions, runs either a shell command or a Node action inside the container, reads back any exported env vars, and patches the step's final status.
Step 5 — Cleanup and final status
In a finally block, the container is force-removed and the temp directory deleted — this runs even if a step throws unexpectedly. Finally the job and run are patched to SUCCEEDED or FAILED based on the accumulated conclusion.
The Setup Phase
Before any user step can run, the worker has to prepare an isolated workspace and a live container. Every command here streams into the "Set up job" step, so a clone or pull failure is visible on the run page and in the worker's terminal.
Temp directory layout
Each job gets a unique temp tree under the OS temp dir, keyed by job ID. Two directories are bind-mounted into the container:
/tmp/seeloud-action-<jobId>/
workspace/ → mounted at /github/workspace (the checked-out repo)
github/ → mounted at /github (runner scratch files)
env → GITHUB_ENV (exports to later steps)
path → GITHUB_PATH
output → GITHUB_OUTPUT
step_summary → GITHUB_STEP_SUMMARY
runner_temp/ → RUNNER_TEMPThese files are pre-created empty so that steps (and actions) can append to them without first checking for existence — mirroring the real GitHub runner's filesystem contract.
Cloning at the exact SHA
The worker clones with git clone --no-tags then git checkout <sha>, guaranteeing the build runs against the precise commit that triggered it — not just the current tip of the branch, which may have moved. When a GitHub token is present it is injected into the clone URL as x-access-token, enabling private-repo checkouts:
const authUrl = githubToken
? `https://x-access-token:${githubToken}@github.com/${repoFullName}.git`
: `https://github.com/${repoFullName}.git`
// git clone --no-tags <authUrl> <workspaceDir>
// git -C <workspaceDir> checkout <sha>Booting the container
The runs-on label is mapped to a Docker image by resolveImage() — today everything (ubuntu-latest, linux, node) resolves to node:20. After docker pull, the container is started detached with tail -f /dev/null as its command — a classic trick that keeps the container alive and idle so we can docker exec each step into it:
docker run -d \
--name seeloud-action-<jobId> \
-v <workspaceDir>:/github/workspace \
-v <githubFilesDir>:/github \
-w /github/workspace \
--env KEY=VALUE ... \ // baseEnv + workflow env + secrets
node:20 \
tail -f /dev/nullThe safe.directory fix
The workspace is owned by the host user (whatever UID the worker runs as), but the container runs as root. Git 2.35+ refuses to operate on a repository owned by a different user — which would break actions/checkout and any run: step that touches git. The fix is to run, once at setup:
git config --global --add safe.directory "*"FAILED, patches the job and run to FAILED, removes the container, deletes the temp dir, and returns early. No user steps execute against a broken workspace.Step Execution
With a live container, the worker walks the step list. Each step passes through the same decision pipeline: should it run, what kind of step is it, and what was the outcome.
Conditions and skipping
Before running, the step's if: condition is interpolated and evaluated by evalCondition, which understands success(), failure(), always(), !cancelled(), and literal true/false. If there is no explicit condition and a previous step already failed, the step is skipped automatically — matching GitHub's default fail-fast behaviour. Skipped steps are patched with status SKIPPED and both timestamps set.
true rather than being treated as false. The reasoning: silently skipping a step the author intended to run is far more confusing than running one extra step. It is a deliberate fail-open choice for an expression evaluator that does not yet cover the full GitHub grammar.run: steps
A run: step's command is interpolated (resolving ${{ github.* }}, ${{ secrets.* }}, ${{ env.* }}) and executed inside the container. The shell defaults to bash but can be overridden per step. Crucially it runs with the -e flag so a failing command aborts the script and surfaces a non-zero exit code:
docker exec \
--env KEY=VALUE ... \ // step-level env overrides
--workdir <working-directory> \ // optional
seeloud-action-<jobId> \
bash -e -c "<interpolated command>"Both stdout and stderr are consumed line-by-line as they arrive (see Log streaming below) and the process exit code becomes the step's pass/fail signal.
uses: steps
uses: steps reference reusable actions like actions/checkout@v4. Resolving and running one is the most involved path in the worker:
- Reference parsing —
owner/repo@refis split with a regex.docker://and composite/docker-type actions are explicitly not yet supported and return a clean error. - Action cache — the action repo is cloned once (
--depth 1 --branch ref) into a process-wide cache underRUNNER_TEMP/seeloud-action-cache/and reused across jobs. If a cached directory exists but is missingaction.yml(a partial clone), it is removed and re-cloned. - Copy into container — the cached action is copied to
/github/actions/<owner>/<repo>viadocker cp. - Inputs — the
with:block becomesINPUT_*env vars (uppercased, spaces to underscores). Defaults declared inaction.ymlfill in anything not explicitly provided, with${{ github.* }}defaults resolved against the container'sGITHUB_*env. - Execution — for
node20/node16actions, the worker runsnode <actionPath>/<runs.main>inside the container.
Passing env between steps
After every step, the worker reads the mounted GITHUB_ENV file and merges any KEY=VALUE exports into a stepEnv map that is layered into subsequent steps. This is how a step that writes echo "VERSION=1.2.3" >> $GITHUB_ENV makes $VERSION available to the next step — exactly as on GitHub.
KEY=VALUE form. GitHub's heredoc-style multiline syntax (NAME<<EOF) is a known limitation noted in the source — a good first contribution if you want to dig in.Log Streaming
Every child process — git, docker, and the step commands — is spawned via Bun.spawn with piped stdout and stderr. A shared consumeStream helper reads each pipe, decodes UTF-8 incrementally, and splits on newlines so partial chunks never corrupt a log line:
buf += decoder.decode(value, { stream: true })
const lines = buf.split('\n')
buf = lines.pop() ?? '' // keep the incomplete tail
for (const line of lines) {
if (line) onLog(line, stream) // 'stdout' | 'stderr'
}Each line is dispatched through an onLog callback that does two things: writes to the worker's own pino logger (stdout → debug, stderr → warn so errors are always visible in the terminal) and POSTs the line to the API at /internal/action-logs tagged with the current step ID. Those rows are what the dashboard renders as a live, per-step log view.
Status changes ride the same authenticated internal API. All calls carry a Bearer {WORKER_SECRET} header; a non-OK response is logged as a warning rather than swallowed, so a secret mismatch is visible immediately instead of silently dropping every log line and status update.
POST /internal/action-logs— one log line.PATCH /internal/action-steps/:id— step status/conclusion/timestamps.PATCH /internal/action-jobs/:id— job status.PATCH /internal/action-runs/:id— overall run status.
The Container Environment
buildBaseEnv constructs the same environment a real GitHub runner exposes, so most actions and scripts work unchanged. It is layered with workflow/job env and decrypted secrets before being passed to the container:
const baseEnv = buildBaseEnv({ repoFullName, sha, ref, event, actor, githubToken })
const jobEnv = { ...baseEnv, ...env, ...decryptedSecrets }| Variable | Default | Description |
|---|---|---|
CI | true | Signals a CI environment to tools. |
GITHUB_ACTIONS | true | Marks the runner as GitHub-Actions-compatible. |
GITHUB_WORKSPACE | /github/workspace | The checked-out repo, bind-mounted from the host. |
GITHUB_ENV | /github/env | File steps append to, to export env to later steps. |
GITHUB_OUTPUT | /github/output | File for step outputs. |
GITHUB_STEP_SUMMARY | /github/step_summary | Markdown job summary file. |
GITHUB_REPOSITORY | owner/repo | Full repository name. |
GITHUB_SHA | — | The commit SHA being built. |
GITHUB_REF | — | Full ref, e.g. refs/heads/main. |
GITHUB_REF_NAME | — | Branch or tag name derived from the ref. |
GITHUB_EVENT_NAME | — | push or pull_request. |
GITHUB_ACTOR | — | The login that triggered the run. |
GITHUB_TOKEN | — | Decrypted access token (only if present). |
RUNNER_OS | Linux | Reported runner OS. |
RUNNER_ARCH | X64 | Reported runner architecture. |
RUNNER_TEMP | /github/runner_temp | Scratch space for actions. |
Concurrency and Configuration
A single worker instance processes up to WORKER_CONCURRENCY jobs at once (default 2), each in its own uniquely-named container and temp directory, so there is no cross-contamination between concurrent runs. Horizontal scaling is trivial: deploy more worker containers pointed at the same Redis, and BullMQ distributes jobs across them with zero coordination.
| Variable | Default | Description |
|---|---|---|
SEELOUD_ACTIONS_INTERNAL_URL | http://localhost:3001 | Base URL of apps/api for internal callbacks (logs, status). |
WORKER_SECRET | — | Shared bearer secret — must match apps/api. |
ENV_ENCRYPTION_KEY | — | 64-char hex key that decrypts the token + secrets — must match apps/api. |
DATABASE_URL | — | Postgres connection string (reads ordered step IDs). |
REDIS_HOST | localhost | Redis host for the seeloud-actions queue. |
REDIS_PORT | 6379 | Redis port. |
WORKER_CONCURRENCY | 2 | Max concurrent Docker containers per worker instance. |
WORKER_SECRET and ENV_ENCRYPTION_KEY must be byte-for-byte identical in both apps/action-worker and apps/api. A secret mismatch makes every internal call return 401 — logs and status updates silently stop; an encryption-key mismatch means the token and secrets decrypt to garbage. Both are the first things to check when a run "hangs" in the UI.Cleanup and Graceful Shutdown
Per-job cleanup lives in a finally block so it runs whether the step loop finished normally or threw: the container is force-removed with docker rm -f and the temp tree is deleted. Both are wrapped in .catch(() => {}) — a cleanup failure should never mask the job's real result.
At the process level, the entry point drains BullMQ on SIGTERM/SIGINT so Docker can stop the container cleanly without abandoning an in-flight run:
async function shutdown() {
logger.info('shutting down action worker')
await worker.close() // stop accepting jobs, finish in-flight work
process.exit(0)
}
process.on('SIGTERM', shutdown)
process.on('SIGINT', shutdown)Conclusion
action-worker reimplements the core of GitHub Actions in a few hundred lines of focused TypeScript: parse a workflow, clone at a SHA, boot a container, run each step, and stream everything back. The design leans on a handful of deliberate choices — a job queue for durable, back-pressured hand-off; a long-lived tail -f /dev/null container that steps exec into; encrypted secrets that only decrypt inside the worker; and the API as the single writer behind authenticated internal callbacks.
It is intentionally not a full GitHub-Actions clone — docker and composite actions, multiline GITHUB_ENV exports, and the complete expression grammar are all still on the roadmap. But for the common case (run: scripts plus popular Node actions like checkout and setup-node) it delivers real CI with live logs and honest pass/fail semantics.
To see it in action, connect a repository in the Seeloud dashboard, push a commit with a workflow file, and watch the logs stream in. Or explore the source under apps/action-worker/ to see the setup, step loop, and cleanup up close.