Use this when defining a GitHub Actions workflow file.
Workflow · GitHub Actions
A GitHub Actions workflow is a YAML file in .github/workflows that defines triggers, jobs and steps, such as building, testing and deploying code on every push.
1. A workflow is a YAML file of jobs triggered by events.
2. Set permissions explicitly.
3. Concurrency groups to avoid overlapping deploys.
4. Reusable workflows for sharing.
5. Lint with actionlint.
YAML → triggers → jobs
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification path Verify boundary
Resolve the exact workflow file and commit used by a run, then inspect event/ref, run ID and the job graph. Confirm expected jobs were created, skipped or cancelled for the right expression/needs/concurrency reason and inspect per-step conclusions. Validate permissions and environment/approval behavior for privileged operations. When matrices are used, verify the expected combinations rather than one representative job. For external deployment, correlate the run with artifact digest/release/resource identifiers and independently read back the target. Re-run a known fixture after workflow changes and compare trigger, job topology and target outcome. A green overall run can still hide intentionally skipped paths, so success is meaningful only when the expected job set and postconditions are demonstrated.
Step 2 Common mistakes Narrow the fault
- Workflows triggered on
pull_request_targetwith untrusted code.
Step 3 Where it fails Narrow the fault
The boundaries are event/run creation, YAML/expression evaluation, permissions/environment approval, runner provisioning, action/step execution, artifact handling and external target behavior. A workflow may exist but never trigger; trigger but skip a job due to if; create a job that waits for approval; run on a healthy runner while an action fails; or complete successfully while an asynchronous deployment later becomes unhealthy. Debug from the run identity outward rather than changing all layers at once. Do not broaden repository/token permissions to work around a target authorization issue until you show the failing identity and scope. Preserve run ID, commit and job/step status before editing YAML, then repeat the same scenario and verify the external postcondition after remediation.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Workflows are YAML files in .github/workflows.
- They define triggers, jobs and steps.
- Syntax errors stop the workflow from running.
actionlint .github/workflows/*.yml— lintgh workflow view <name>— details- permissions: block at top — least privilege
ReferenceWhy it matters1 section · depth on demand
In depth
In GitHub Actions, a workflow is a YAML file in .github/workflows/ that defines triggers (on:), permissions, environment variables and one or more jobs. Each run of the workflow appears in the Actions tab with its logs.
name: deploy-network
on:
push: { branches: [main], paths: ['network/**'] }
workflow_dispatch:
permissions:
contents: read
concurrency: { group: deploy-network, cancel-in-progress: false }
concurrency prevents two deployments of the same thing running at once, and paths filters avoid running for unrelated changes.
ReferenceImportant terms & boundaries1 section · depth on demand
Mechanics
A GitHub Actions workflow is a YAML-defined automation graph stored under .github/workflows. The on section determines run creation, while jobs form the main execution units and steps run actions or shell commands on a runner. Jobs can depend on other jobs through needs, be gated by expressions, expand through matrices and receive permissions, environments, secrets, variables and contexts from several scopes. Runner selection and action implementation introduce further runtime dependencies. Workflow-level and job-level concurrency can cancel or serialize runs, and defaults/permissions can be overridden at narrower scopes. A workflow run therefore materializes more than a YAML file: event payload, repository/ref/commit, workflow definition, contexts, permissions, selected runner image, referenced action versions and external targets all contribute to behavior.
ReferenceConfiguration & state1 section · depth on demand
Lifecycle
Keep workflow files under normal pull-request review and protect sensitive deployment paths with least-privilege permissions, environments and required approvals. Pin third-party actions to reviewed immutable commits where supply-chain risk warrants it, and periodically update those pins deliberately. Treat reusable workflows and composite actions as dependencies with their own version contracts. Changes to matrices, needs, concurrency and trigger filters can alter execution topology even when individual steps are unchanged, so include them in regression review. Avoid encoding secrets in YAML or echoing whole contexts. Separate build/test artifacts from deployment credentials and define retention intentionally. When deprecating a workflow, migrate schedules/callers and disable triggers rather than leaving two workflows racing to manage the same target.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in GitHub Actions > Workflow. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax · confidence 94%Quick lookup tables
GitHub Actions → Workflow · operational reference
Context-specific ownership, verification, output and failure-boundary lookup for GitHub Actions → Workflow.
| Layer | GitHub Actions → Workflow operational reference |
|---|---|
| Context identity | GitHub Actions current + exact revision/input/target identity |
| Persistent intent | Versioned contract/configuration with explicit ownership and prerequisites |
| Verification | Validate inputs/read current state → exercise bounded operation → independent target read-back |
| Output contract | Preserve structured status/IDs/properties before human formatting |
| Failure boundary | Separate source/input/engine/controller execution from downstream target outcome |
Deep reference
Healthy vs suspicious evidence
Output interpretation
Workflow output spans run metadata, job conclusions, step logs, annotations, artifacts and summaries. Record run ID, event, ref/head SHA, workflow path, actor, selected environment, concurrency/cancellation reason and job/step conclusions. Logs should support diagnosis but are not a stable machine contract; prefer JSON/API metadata, artifact digests and explicit outputs for automation-to-automation integration. Treat deprecated set-output-style assumptions carefully and use documented environment/output files or action outputs. Do not expose secrets by printing contexts, command lines or environment indiscriminately. For deployment workflows, publish a concise summary of artifact/version and target result while retaining detailed logs separately. Correlate asynchronous external operations with their resource/job IDs before declaring completion.