Custom Steps and Jobs

Custom steps and jobs let you mix deterministic computation with agentic execution. Custom steps and jobs run outside the firewall sandbox with standard GitHub Actions security, unless a run: step opts in with step-level network: or sandbox:.

See DeterministicOps for patterns combining computation with AI reasoning.

Use these top-level step hooks in this order:

  1. pre-steps: — runs before checkout and all later built-in agent-job setup (only compiler-injected OTLP masking steps may run earlier). Use it for short-lived token minting or anything that must precede checkout.
  2. steps: — runs after checkout and runtime/bootstrap steps, before the final pre-agent phase. Use it for deterministic preprocessing that needs the checked-out repository.
  3. pre-agent-steps: — runs after framework initialization (checkout cleanup, base-branch restoration) and before MCP startup and engine execution. Use it for last-moment environment preparation.
  4. post-steps: — runs after the engine finishes. Use it for cleanup, summaries, uploads, or follow-up automation.
pre-steps:
- name: Mint checkout token
id: checkout_app
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
repositories: ${{ github.repository }}
permission-contents: read

Every actions/create-github-app-token step needs explicit repositories and permission-* inputs; otherwise the token can inherit access across the App installation. repositories: ${{ github.repository }} scopes the token to the current repository. If you set owner to a different installation owner, list that owner’s repositories explicitly. The compiler warns when either input is missing and rejects the workflow in strict mode. Job-level permissions: does not scope the App token.

Use pre-steps when later checkout or setup must consume outputs from a step in the same job.

For compiler-managed token wiring, give the official actions/create-github-app-token action the reserved id: create-token. Only that action with that ID triggers token wiring and automatic OIDC permissions; similarly named third-party actions do not. The compiler prefers this step’s output for compiler-owned default GitHub token bindings later in the same job. Authored step environments and explicit credentials are left unchanged. It also adds id-token: write to the minting job unless id-token: none is set or safe-outputs.id-token: none disables automatic grants.

permissions:
contents: read
id-token: write
pre-steps:
- name: Retrieve centrally managed GitHub credential
id: plugin_credentials
uses: octo-org/central-credentials-action@0123456789abcdef0123456789abcdef01234567
plugins:
- plugin: octo-org/private-agent-plugin@0123456789abcdef0123456789abcdef01234567
github-token: ${{ steps.plugin_credentials.outputs.github_token }}

pre-steps and Agent Plugin checkout run in the same generated agent job, so plugin auth can use ${{ steps.<id>.outputs.<name> }} (or ${{ env.<name> }} when an action exports credentials through $GITHUB_ENV). ${{ needs.<job>.outputs.<name> }} crosses a job boundary and may be unsuitable for masked credentials.

Add custom steps before agentic execution. If unspecified, a default checkout step is added automatically.

steps:
- name: Install dependencies
run: npm ci

Steps can also short-circuit the agent by writing a noop entry to $GH_AW_SAFE_OUTPUTS — the harness detects this at startup and exits cleanly without incurring any AI inference cost. See Skip the Agent When It Is Not Needed for details.

See Checkout and Host Step Order for checkout ordering, untrusted-ref warnings, and safe handling of fetched refs.

Add custom steps before MCP gateway startup in the agent job so prerequisite MCP installation/configuration can happen first.

pre-agent-steps:
- name: Finalize Context
run: ./scripts/prepare-agent-context.sh

Add custom steps after agentic execution. Run after the AI engine completes regardless of success/failure (unless conditional expressions are used).

post-steps:
- name: Upload Results
if: always()
uses: actions/upload-artifact@v4
with:
name: workflow-results
path: /tmp/gh-aw/agent/
retention-days: 7

Post-steps must not create issues directly, read safe-output files, or expose secrets through a step-level env section. Avoid uploading the entire /tmp/gh-aw/ directory, which can contain protected safe-output files. Use safe-outputs.create-issue to publish agent-generated issues instead.

Add network: or sandbox: to a run: step in pre-steps:, steps:, pre-agent-steps:, post-steps:, or a custom job’s jobs.<job-id>.pre-steps: or jobs.<job-id>.steps: to run its script inside AWF (the Agent Workflow Firewall). The compiler removes these keys, compiles them into an AWF config passed in the step’s env:, and sets a custom shell that runs the script with awf --config.

steps:
- name: Install dependencies
run: npm ci
network:
allowed: [node, "*.example.org"]
blocked: [tracker.example.org]
firewall:
log-level: debug
sandbox:
memory: 4g
- name: Offline test
run: npm test
network:
allowed: [] # deny all egress

Compiles to (abbreviated):

- name: Install dependencies
run: npm ci
env:
GH_AW_AWF_CONFIG: '{"$schema":"...","network":{"allowDomains":["*.example.org","registry.npmjs.org",...],"blockDomains":["tracker.example.org"]},"container":{"imageTag":"...","memoryLimit":"4g"},"environment":{"envAll":true,"excludeEnv":[...]},"logging":{"logLevel":"debug"}}'
GH_AW_AWF_MOUNTS: ""
GH_AW_AWF_RUN: cd "$GITHUB_WORKSPACE" && exec bash -e /tmp/gh-aw-sandboxed-run/step

The generated shell uses /bin/bash, sets a trusted host PATH, clears ambient OTLP and API endpoint variables that could expand AWF’s network policy, and invokes a checksum-verified native AWF binary by absolute path under $RUNNER_TEMP. The AWF binary and its runtime are not mounted into the sandbox. The shell creates a private staging directory under $RUNNER_TEMP, which the AWF sandbox does not mount, copies the runner’s script there, and mounts it read-only at /tmp/gh-aw-sandboxed-run/step. The staging directory is removed when AWF exits, and AWF’s exit code is kept. The config uses the same schema as the agent step’s AWF config.

FieldDescription
network.allowedDomains, wildcard domains, and ecosystem identifiers. [] blocks all egress. Defaults to [defaults] when only sandbox: is set. * is rejected.
network.blockedDomains or ecosystems to block.
network.firewall.log-leveldebug, info (default), warn, or error.
sandbox.mountsCurrently unsupported. Any non-empty list is rejected because lexical path checks cannot rule out symlink, bind-mount, or implicit Docker socket aliases.
sandbox.memoryContainer memory limit, for example 4g or 512m.

Behavior and limitations:

  • The top-level network: setting is not inherited; each step declares its own policy.
  • Sandboxed steps require AWF v0.29.15 or newer (the default version qualifies), because they use AWF --home. Compilation fails if sandbox.agent.version or network.firewall.version selects an older release. They are not supported with runner.topology: arc-dind.
  • Only run: steps are supported, on Linux runners. Supported shells are the default (bash -e), bash, sh, python, and single-line custom templates containing {0}. Custom templates must be literal: expressions, $, backticks, and braces other than {0} are rejected. pwsh, powershell, and cmd are rejected.
  • The step’s environment is forwarded into the sandbox, subject to AWF’s credential filtering and these exclusions: GH_AW_AWF_CONFIG, GH_AW_AWF_MOUNTS and GH_AW_AWF_RUN (reserved), OIDC token request variables (ACTIONS_ID_TOKEN_REQUEST_*), OTLP exporter and API endpoint variables, and host temp paths. HOME is a fresh empty directory for each step (see below). The script runs in $GITHUB_WORKSPACE, or in a literal working-directory: relative to it. Expressions in working-directory: are rejected.
  • The compiler installs a dedicated, checksum-verified native AWF binary under $RUNNER_TEMP/gh-aw-sandboxed-run-awf before the first sandboxed step. Its private path is not added to PATH; the generated shell invokes it by absolute path. This prevents a prior agent from replacing the launcher through its writable home tool directories or a PATH entry.
  • In a custom job that contains sandboxed steps, the compiler injects the gh-aw setup action (unless restore-memory already added it) and the AWF install after the compiler host setup and before pre-steps. Sandboxed steps are rejected in jobs.<job-id>.setup-steps, which run before AWF is installed.
  • network: or sandbox: anywhere else, such as on.steps: or jobs.<built-in-job>.setup-steps:, pre-steps:, or steps: (for example jobs.activation.steps or jobs.agent.pre-steps), is a compile error rather than being ignored, so a step that requests isolation never runs on the host.
  • Sandboxed steps run sequentially. background: on a sandboxed step, and sandboxed steps inside a parallel: group, are rejected because AWF runs one sandbox at a time on a runner.
  • Each sandboxed step runs AWF with --home set to a fresh, empty directory that is deleted after the step. AWF mounts home tool directories (such as ~/.local/bin, ~/.cargo, and ~/.npm) from that directory instead of the runner’s home, so tools installed there (for example by pipx, rustup, or nvm) are unavailable inside the sandbox. Use tools from system paths, or install them inside the step.
  • The sandbox is not a disposable filesystem or credential boundary. $GITHUB_WORKSPACE and /tmp/gh-aw stay writable, so changes persist into later steps; validate files before a later host step executes them. EnvAll remains subject to AWF’s credential filtering, not a guarantee that every job or step secret is absent. Explicitly passed credentials remain available to sandboxed code, and sandboxing does not reduce the job’s GitHub token permissions.
  • The compiler currently rejects every non-empty sandbox.mounts list. This prevents author-supplied mounts from creating a Docker socket alias, but does not resolve possible socket exposure through AWF’s implicit mounts. Do not treat this experimental feature as a security boundary or use it with untrusted code until that residual risk is resolved.
  • For each executed sandboxed step in the agent job, the unified agent session records a metadata-only execution.result event (outcome, exit code, and duration); skipped steps have no event. It does not collect scripts, stdout/stderr, environment variables, AWF configuration, or per-request firewall activity. Custom-job sandboxed steps are not included in this session record. Actions job logs can contain output and AWF messages; the session is not a complete audit.
  • GitHub Actions still evaluates expressions in run: before the shell starts. Pass untrusted values through env: and use quoted variable expansions rather than interpolating them into shell source.
  • The agent step mounts runner-home tool directories read-write. Ordinary host steps after the agent may therefore see modified home files; the dedicated AWF launcher protects sandboxed run steps, not arbitrary host commands or files in the workspace.

Define custom jobs that run before agentic execution. The agentic execution job waits for all custom jobs to complete. Custom jobs can share data with the agent through artifacts or job outputs.

To run a custom job after agentic execution, add needs: [agent, detection] (or needs: detection if agent outputs are not referenced directly). The compiler also recognizes transitive post-agent dependencies. When detection is enabled, every downstream custom job gets a direct detection dependency and a non-overridable success guard. Failed, cancelled, skipped, missing, or warn-mode flagged results block it, including reusable workflow calls and if: always() jobs. Custom jobs cannot run between agent and detection. Disabling detection removes this gate.

For notifications that must run even when detection fails or flags warn-mode findings, mark a leaf custom job detection-gate: status-only:

jobs:
status:
needs: [agent, detection, safe_outputs]
detection-gate: status-only
if: always()
runs-on: ubuntu-latest
steps:
- run: echo "${{ needs.agent.result }} ${{ needs.detection.result }} ${{ needs.safe_outputs.outputs.created_issue_number }}"

The compiler adds detection to needs if needed and keeps the authored if. The job may read outputs from detection-gated compiler-owned jobs (such as safe_outputs) and from custom jobs that run before agent with no direct or transitive dependency on agent or detection. For example, a reporter can use a validated PR number and head SHA from pre-agent metadata even when detection fails. Declare each metadata job in needs and pass its outputs through env; never interpolate custom outputs directly into run or actions/github-script code.

The compiler rejects the opt-out if the job downloads artifacts, calls an opaque reusable workflow, reads other job outputs, or references GH_AW_AGENT_OUTPUT or agent/safe-output files in env or run. Other custom jobs cannot depend on a job using this option. The detection-gate key is compiler-only and is not emitted in the Actions workflow. See Custom job detection gates.

jobs:
super_linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Run Super-Linter
uses: super-linter/super-linter@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FieldDescription
nameDisplay name for the job
needsJobs that must complete before this job runs
runs-onRunner label — string, array, or object form
ifConditional expression to control job execution
permissionsGitHub token permissions for this job
outputsValues exposed to downstream jobs
envEnvironment variables available to all steps
timeout-minutesMaximum job duration (GitHub Actions default: 360)
concurrencyConcurrency group to prevent parallel runs
continue-on-errorAllow the workflow to continue if this job fails
containerDocker container to run steps in
servicesService containers (e.g. databases)
setup-stepsSteps injected immediately after the compiler-generated actions/setup step for that job (except activation and pre_activation, where compile fails)
pre-stepsSteps injected after compiler setup steps and before checkout/steps in that job
stepsList of steps — supports complete GitHub Actions step specification
restore-memoryRestore configured memory stores read-only before pre-steps/steps so deterministic jobs can read prior state
usesReusable workflow to call
withInput parameters for a reusable workflow
secretsSecrets passed to a reusable workflow

The strategy field (matrix builds) is not supported.

runs-on accepts a string, an array of runner labels, or the object form:

jobs:
build:
runs-on:
group: my-runner-group
labels: [self-hosted, linux]
steps:
- uses: actions/checkout@v7

When imports define the same jobs.<job-id>.setup-steps or jobs.<job-id>.pre-steps, gh-aw merges that field deterministically: imported steps run first, then main-workflow steps. The two fields stay separate; setup-steps are never folded into pre-steps or vice versa.

Use this map to see where compiler-inserted steps land for each job type.

jobs.<job-id> steps run in this order:

  1. jobs.<job-id>.setup-steps
  2. Compiler host setup (Configure GH_HOST for enterprise compatibility)
  3. restore-memory injected setup/restore steps (when enabled)
  4. gh-aw setup and AWF install (when the job has sandboxed run steps)
  5. jobs.<job-id>.pre-steps
  6. jobs.<job-id>.steps

Set jobs.<job-id>.restore-memory: true to restore configured cache-memory, repo-memory, and comment-memory stores before deterministic job steps run. This is read-only: gh-aw never emits cache save, repo push, or safe-output write-back steps for custom jobs.

Custom jobs can also depend on enabled post-agent maintenance jobs. For example, with tools.repo-memory configured, needs: [push_repo_memory] runs after the agent and the repo-memory push without listing agent. Other post-agent maintenance job IDs are update_cache_memory, update_drive_memory, push_ledger_changes, and push_evals_state. Experiment persistence (push_experiments_state) runs after activation rather than after the agent.

JobStep order
pre_activationjobs.pre_activation.setup-steps is refused at compile time to prevent short-circuiting protections; use jobs.pre_activation.pre-steps and jobs.pre_activation.steps
activationjobs.activation.setup-steps is refused at compile time to prevent short-circuiting protections; use jobs.activation.pre-steps
agentjobs.agent.setup-steps → compiler setup checkout/setup → jobs.agent.pre-steps → runtime path setup → top-level pre-steps → checkout/token/runtime/custom/agent steps
safe_outputsjobs.safe_outputs.setup-steps → compiler setup checkout/setup → jobs.safe_outputs.pre-steps → safe-outputs downloads/prep → GitHub App token minting → safe-output handlers/finalization
conclusionCompiler-generated steps only; user setup-steps, pre-steps, and steps are rejected
gradersCompiler-owned restricted job after conclusion, generated only for custom JavaScript graders; no job customization or inherited environment
detectionjobs.detection.setup-steps → compiler setup checkout/setup → jobs.detection.pre-steps → built-in detection steps
unlockjobs.unlock.setup-steps → compiler setup checkout/setup → jobs.unlock.pre-steps → built-in unlock steps

Built-in job sections support additive needs and if overrides, for example to gate the generated agent job on a custom setup job:

jobs:
build:
runs-on: ubuntu-latest
outputs:
outcome: ${{ steps.result.outputs.outcome }}
steps:
- id: result
run: echo "outcome=failure" >> "$GITHUB_OUTPUT"
agent:
needs: [build]
if: needs.build.outputs.outcome == 'failure'

jobs.<built-in>.needs is merged with compiler-generated dependencies, and jobs.<built-in>.if is combined with compiler-generated conditions using logical &&. jobs.agent.continue-on-error accepts a boolean and applies it to the generated agent job; other built-in jobs reject this field. jobs.<built-in>.timeout-minutes is accepted for the agent and detection jobs only; see Agent and Detection Job Timeouts.

Example using timeout-minutes and env:

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
NODE_ENV: production
steps:
- uses: actions/checkout@v7
- run: npm ci && npm run build

The generated agent and detection jobs are bounded by their own timeout-minutes values, independently from the top-level timeout-minutes that bounds the agentic_execution step:

TimeoutDefaultGitHub Actions variable
agent job60 minutesGH_AW_DEFAULT_AGENT_JOB_TIMEOUT_MINUTES
detection job and its execution step10 minutesGH_AW_DEFAULT_DETECTION_JOB_TIMEOUT_MINUTES
agentic_execution step (top-level timeout-minutes)20 minutesGH_AW_DEFAULT_TIMEOUT_MINUTES

Set those variables at the repository, organization, or enterprise level to change the defaults without editing frontmatter. When top-level timeout-minutes requests a longer agentic step than the default agent job budget, the default agent job budget is raised to match it.

Override either generated job independently when setup or post-processing needs a different budget:

jobs:
agent:
timeout-minutes: 90
detection:
timeout-minutes: 30

On timeout, GitHub Actions cancels the job’s remaining steps and reports the job as timed_out. The budget covers setup steps as well as the agentic execution step.

Custom jobs can expose outputs accessible in the agentic execution prompt via ${{ needs.job-name.outputs.output-name }}:

jobs:
release:
outputs:
release_id: ${{ steps.get_release.outputs.release_id }}
version: ${{ steps.get_release.outputs.version }}
steps:
- id: get_release
run: echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
Generate highlights for release ${{ needs.release.outputs.version }}.

Job outputs must be string values. Quote literals that YAML would otherwise interpret as booleans, numbers, or null, and use '' for an empty string:

outputs:
actor_trusted: 'true'
count: '42'
missing: 'null'
empty: ''

The compiler preserves these string values for custom jobs, pre_activation (also spelled pre-activation), and custom safe-output jobs. Expressions keep their syntax.