Use this when building CI/CD and automation with GitHub Actions workflows.
GitHub Actions
GitHub Actions is GitHub's built-in CI/CD and automation service. Workflows in .github/workflows run jobs of steps on GitHub-hosted or self-hosted runners when events such as push or pull_request happen.
1. GitHub Actions: workflows in .github/workflows triggered by events.
2. Pin actions to commit SHAs.
3. Least-privilege GITHUB_TOKEN permissions.
4. OIDC for cloud.
5. Protect environments.
event → workflow → jobs on runners → steps
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 Target-state verification ladder Verify boundary
GitHub Actions uses a strict target-state ladder for workflow job/runner action: request accepted → job/task succeeded → target object changed → effective runtime state confirmed → original workload verified.
Step 2 Verification path Verify boundary
For a workflow under investigation, identify the exact run ID, event, ref/head SHA and workflow file revision. Inspect job expansion, runner assignment, permissions and step conclusions rather than relying on the repository-level badge. Reproduce a safe run with controlled inputs and verify expected skipped/conditional paths. For deployment workflows, correlate the run to a deployment/environment record and independently query the target service/version after completion. Test at least one denied-permission or invalid-input case so security and failure reporting are understood. For reusable workflows, verify caller inputs and callee revision. A green Actions run shows that its configured steps concluded successfully; it does not by itself show application health or that the desired artifact is serving traffic.
Step 3 Where it fails Narrow the fault
Separate event/trigger evaluation, workflow parsing, permissions/context resolution, job scheduling, runner execution, third-party action behavior and external target outcome. A workflow may not run because filters excluded it, a job may wait for a runner, a step may fail because an action dependency changed, or deployment may fail after all local build steps passed. Self-hosted runner failure is not repository logic failure. Do not rerun blindly until you know whether the previous attempt mutated an external target. Pinpoint the earliest missing expected state using run/job/step IDs, then inspect the adjacent layer. If a deployment action reports success but verification fails, preserve both records and diagnose the external target separately. Re-run the original workflow/consumer check 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.
Subtopics
Go one level deeper into this subject.
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.
Subtopic EventsEvents trigger GitHub Actions workflows, defined under on:, such as push, pull_request, schedule, workflow_dispatch for manual runs, release or repository_dispatch from external systems.
Subtopic JobsJobs in a GitHub Actions workflow run on separate runners, in parallel by default or in order with needs:, and each job is a sequence of steps sharing one workspace.
Subtopic StepsSteps are the individual commands or actions in a job, run in order with run: for shell commands or uses: for actions, sharing the workspace and environment.
Subtopic ActionsActions are reusable steps in GitHub Actions workflows, referenced with uses: such as actions/checkout@v4.
Subtopic RunnersRunners are the machines that execute GitHub Actions jobs, either GitHub-hosted or self-hosted, selected with runs-on labels.
Subtopic GitHub-hosted RunnerGitHub-hosted runners are fresh VMs (Ubuntu, Windows, macOS) that GitHub provides for each job, selected with runs-on: ubuntu-latest, with common tools preinstalled and no maintenance.
Subtopic Self-hosted RunnerSelf-hosted runners are your own machines running the GitHub Actions runner agent, used for special hardware, private network access or cost.
Subtopic VariablesVariables in GitHub Actions are non-secret configuration values set at repository, environment or organization level and read with ${{ vars.NAME }}, plus env: values within workflows.
Subtopic SecretsSecrets in GitHub Actions are encrypted values stored at repository, environment or organization level and read as ${{ secrets.NAME }}.
Subtopic EnvironmentsEnvironments in GitHub Actions group deployment targets like staging and production with their own secrets, required reviewers, wait timers and branch restrictions.
Subtopic Matrix StrategyA matrix strategy runs one job across combinations of variables, such as several OS and language versions, using strategy.matrix, with fail-fast and max-parallel controls.
Subtopic ArtifactsArtifacts in GitHub Actions are files saved from a job with actions/upload-artifact and downloaded in later jobs or from the run page, such as build outputs or test reports, with a retention period.
Subtopic CachingCaching in GitHub Actions stores dependencies like npm, pip or Maven files between runs with actions/cache or setup-* cache options, keyed by lock-file hashes to speed up builds.
Subtopic Reusable WorkflowsReusable workflows are called from other workflows with uses: owner/repo/.github/workflows/file.yml@ref and workflow_call inputs and secrets, sharing standard pipelines across repositories.
Subtopic GitHub Actions TroubleshootingTroubleshoot GitHub Actions by reading the step logs, enabling debug logging (ACTIONS_STEP_DEBUG), checking the trigger and path filters, permissions of GITHUB_TOKEN, secrets availability on forks and runner labels.
- Pin third-party actions to a commit SHA.
- Grant GITHUB_TOKEN least privilege.
- Secrets are not passed to forked pull requests.
gh workflow list— workflowsgh run list --limit 10— recent runsactionlint— lint workflow files
ReferenceWhy it matters1 section · depth on demand
In depth
GitHub Actions is GitHub's built-in CI/CD: YAML workflows in .github/workflows/ run jobs on GitHub-hosted or self-hosted runners in response to repository events.
name: ci
on: [pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install ansible-lint && ansible-lint
| Feature | Use |
|---|---|
| Marketplace actions | Reusable steps |
| Environments | Approvals and environment secrets |
| OIDC | Cloud access without stored keys |
| Reusable workflows | Shared pipelines across repos |
Pin third-party actions to a commit SHA and set minimal permissions: for the GITHUB_TOKEN.
ReferenceImportant terms & boundaries1 section · depth on demand
Mechanics
GitHub Actions executes repository-defined workflows when configured events, manual dispatches, schedules or reusable-workflow calls create workflow runs. A workflow run contains jobs; jobs are scheduled onto GitHub-hosted or self-hosted runners and contain ordered steps/actions. Contexts, expressions, secrets, environment protection and GITHUB_TOKEN permissions are evaluated at different scopes, so the same YAML can behave differently by event type, ref or environment. Matrix expansion creates multiple job instances, while needs forms job dependencies. Actions themselves may be JavaScript, container or composite implementations and are supply-chain dependencies. The workflow run conclusion is therefore the result of a controller/runner pipeline, not direct evidence of an external deployment or service state.
ReferenceConfiguration & state1 section · depth on demand
Lifecycle
Keep workflow YAML under review in .github/workflows, pin third-party actions to trusted versions or immutable commits according to risk, and minimize GITHUB_TOKEN/secret permissions at workflow and job scope. Treat runner images and self-hosted runner configuration as execution dependencies; self-hosted runners require patching, isolation and cleanup ownership. Use environments for deployment policy/approval where appropriate and separate build/test credentials from production deployment credentials. Reusable workflows should expose explicit inputs/secrets and versioning so callers do not depend on hidden repository state. Changes to triggers, permissions, action versions, runner labels or branch protection can materially change behavior and should be tested on non-production targets. Retain run IDs and artifacts long enough for release traceability.
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. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.github.com/en/actions/get-started/understand-github-actions · confidence 94%Quick lookup tables
→ GitHub Actions · operational reference
Context-specific ownership, verification, output and failure-boundary lookup for → GitHub Actions.
| Layer | GitHub Actions operational reference |
|---|---|
| Runtime/ownership | GitHub Actions current · identify controller/worker/target ownership before mutation |
| Persistent intent | Versioned configuration/playbook/workflow with explicit dependencies and least-privilege identity |
| Verification | gh run list --limit 10; gh run view <run-id> --json status,conclusion,event,headSha,jobs |
| Expected interpretation | The workflow trigger, revision, permissions, runner environment, jobs and final conclusion are tied to one run ID, and deployment state is verified outside the workflow status. |
| Recovery boundary | Preserve correlation IDs + pre-state, then verify target/service independently after remediation |
Deep reference
Healthy vs suspicious evidence
Output interpretation
Preserve run ID, workflow name/path, event, actor, head SHA/ref, attempt number, job IDs, runner names/labels, step conclusions and deployment/environment identifiers. Console logs are useful but can be truncated or redacted; structured run/job metadata is a more stable index. Distinguish status (queued/in_progress/completed) from conclusion (success/failure/cancelled/skipped/etc.). Matrix jobs need their dimension values retained so one failing variant is identifiable. Artifacts and test reports should be linked to the producing job/revision. Secret masking is not a substitute for avoiding secret output. For deployment, include an external target version/read-back so “workflow success” and “service success” are not collapsed into one field.