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.
Choosing the Right Step Hook
Section titled “Choosing the Right Step Hook”Use these top-level step hooks in this order:
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.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.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.post-steps:— runs after the engine finishes. Use it for cleanup, summaries, uploads, or follow-up automation.
Custom Pre-Checkout Steps (pre-steps:)
Section titled “Custom Pre-Checkout Steps (pre-steps:)”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: readEvery 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.
Custom Steps (steps:)
Section titled “Custom Steps (steps:)”Add custom steps before agentic execution. If unspecified, a default checkout step is added automatically.
steps: - name: Install dependencies run: npm ciSteps 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.
Custom Pre-Agent Steps (pre-agent-steps:)
Section titled “Custom Pre-Agent Steps (pre-agent-steps:)”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.shCustom Post-Execution Steps (post-steps:)
Section titled “Custom Post-Execution Steps (post-steps:)”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: 7Post-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.
Sandboxed Run Steps (Experimental)
Section titled “Sandboxed Run Steps (Experimental)”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 egressCompiles 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/stepThe 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.
| Field | Description |
|---|---|
network.allowed | Domains, wildcard domains, and ecosystem identifiers. [] blocks all egress. Defaults to [defaults] when only sandbox: is set. * is rejected. |
network.blocked | Domains or ecosystems to block. |
network.firewall.log-level | debug, info (default), warn, or error. |
sandbox.mounts | Currently unsupported. Any non-empty list is rejected because lexical path checks cannot rule out symlink, bind-mount, or implicit Docker socket aliases. |
sandbox.memory | Container 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 ifsandbox.agent.versionornetwork.firewall.versionselects an older release. They are not supported withrunner.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, andcmdare 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_MOUNTSandGH_AW_AWF_RUN(reserved), OIDC token request variables (ACTIONS_ID_TOKEN_REQUEST_*), OTLP exporter and API endpoint variables, and host temp paths.HOMEis a fresh empty directory for each step (see below). The script runs in$GITHUB_WORKSPACE, or in a literalworking-directory:relative to it. Expressions inworking-directory:are rejected. - The compiler installs a dedicated, checksum-verified native AWF binary under
$RUNNER_TEMP/gh-aw-sandboxed-run-awfbefore the first sandboxed step. Its private path is not added toPATH; the generated shell invokes it by absolute path. This prevents a prior agent from replacing the launcher through its writable home tool directories or aPATHentry. - In a custom job that contains sandboxed steps, the compiler injects the gh-aw setup action (unless
restore-memoryalready added it) and the AWF install after the compiler host setup and beforepre-steps. Sandboxed steps are rejected injobs.<job-id>.setup-steps, which run before AWF is installed. network:orsandbox:anywhere else, such ason.steps:orjobs.<built-in-job>.setup-steps:,pre-steps:, orsteps:(for examplejobs.activation.stepsorjobs.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 aparallel:group, are rejected because AWF runs one sandbox at a time on a runner. - Each sandboxed step runs AWF with
--homeset 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 bypipx,rustup, ornvm) 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_WORKSPACEand/tmp/gh-awstay writable, so changes persist into later steps; validate files before a later host step executes them.EnvAllremains 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.mountslist. 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.resultevent (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 throughenv: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.
Custom Jobs (jobs:)
Section titled “Custom Jobs (jobs:)”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 }}Supported Job-Level Fields
Section titled “Supported Job-Level Fields”| Field | Description |
|---|---|
name | Display name for the job |
needs | Jobs that must complete before this job runs |
runs-on | Runner label — string, array, or object form |
if | Conditional expression to control job execution |
permissions | GitHub token permissions for this job |
outputs | Values exposed to downstream jobs |
env | Environment variables available to all steps |
timeout-minutes | Maximum job duration (GitHub Actions default: 360) |
concurrency | Concurrency group to prevent parallel runs |
continue-on-error | Allow the workflow to continue if this job fails |
container | Docker container to run steps in |
services | Service containers (e.g. databases) |
setup-steps | Steps injected immediately after the compiler-generated actions/setup step for that job (except activation and pre_activation, where compile fails) |
pre-steps | Steps injected after compiler setup steps and before checkout/steps in that job |
steps | List of steps — supports complete GitHub Actions step specification |
restore-memory | Restore configured memory stores read-only before pre-steps/steps so deterministic jobs can read prior state |
uses | Reusable workflow to call |
with | Input parameters for a reusable workflow |
secrets | Secrets 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@v7When 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.
Jobs and Steps
Section titled “Jobs and Steps”Use this map to see where compiler-inserted steps land for each job type.
Custom jobs
Section titled “Custom jobs”jobs.<job-id> steps run in this order:
jobs.<job-id>.setup-steps- Compiler host setup (
Configure GH_HOST for enterprise compatibility) restore-memoryinjected setup/restore steps (when enabled)- gh-aw setup and AWF install (when the job has sandboxed run steps)
jobs.<job-id>.pre-stepsjobs.<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.
Built-in jobs
Section titled “Built-in jobs”| Job | Step order |
|---|---|
pre_activation | jobs.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 |
activation | jobs.activation.setup-steps is refused at compile time to prevent short-circuiting protections; use jobs.activation.pre-steps |
agent | jobs.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_outputs | jobs.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 |
conclusion | Compiler-generated steps only; user setup-steps, pre-steps, and steps are rejected |
graders | Compiler-owned restricted job after conclusion, generated only for custom JavaScript graders; no job customization or inherited environment |
detection | jobs.detection.setup-steps → compiler setup checkout/setup → jobs.detection.pre-steps → built-in detection steps |
unlock | jobs.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 buildAgent and Detection Job Timeouts
Section titled “Agent and Detection Job Timeouts”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:
| Timeout | Default | GitHub Actions variable |
|---|---|---|
agent job | 60 minutes | GH_AW_DEFAULT_AGENT_JOB_TIMEOUT_MINUTES |
detection job and its execution step | 10 minutes | GH_AW_DEFAULT_DETECTION_JOB_TIMEOUT_MINUTES |
agentic_execution step (top-level timeout-minutes) | 20 minutes | GH_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: 30On 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.
Job Outputs
Section titled “Job Outputs”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_OUTPUTGenerate 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.
Learn More
Section titled “Learn More”- DeterministicOps — Patterns combining deterministic steps with AI reasoning
- Frontmatter Reference — Complete frontmatter field reference
- Custom Safe Outputs — Custom post-processing jobs for agentic outputs
- Imports — Composing
pre-agent-stepsandpost-stepsacross shared workflows