# Managed Runners

The Lunar CI Action is the easiest way to add the Lunar CI Agent to your GitHub Actions workflows. It works with both **GitHub-hosted** and **self-hosted** runners.

For **GitHub-hosted runners** (managed runners), this action is the only installation method — you cannot modify the runner startup process.

For **self-hosted runners**, you can either use this action or configure the agent to [wrap the runner's `run.sh` command](/install/lunar-ci-agent/agent-self-hosted.md) directly, which avoids adding a step to every job.

## Setup

Add the Lunar CI Action as an early step in your workflow jobs:

```yaml
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Run Lunar CI Agent
        uses: earthly/lunar-ci-action@<latest-tag>
        env:
          LUNAR_HUB_TOKEN: ${{ secrets.LUNAR_HUB_TOKEN }}
          LUNAR_HUB_HOST: your_hub_host

      - uses: actions/checkout@v4
      # ... rest of your workflow
```

The action downloads the Lunar CI Agent, then attaches the agent to the job process. All subsequent steps in the job are automatically instrumented.

## How It Works

The action runs as a step in a job. It attaches to the current shell process via ptrace and traces all commands executed by subsequent steps. The agent exits automatically when the job completes.

The same [configuration reference](/install/lunar-ci-agent/agent-config.md) applies. The only difference is that `LUNAR_RUN_CMD` is not needed — the action handles process supervision internally.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-lunar.earthly.dev/install/lunar-ci-agent/agent-managed.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
