supraj.dev

Interview questions & answers

GitHub Actions

Workflows, actions, runners, and CI/CD automation.

  • 30 questions
  • 18 medium
  • 12 hard
  • 3 related articles

30 questions

Question 1Medium

Explain the key differences between composite actions, Docker container actions, and JavaScript actions in GitHub Actions. When would you choose each type, and how does action versioning (@v1, @v1.2, @sha) affect consumers?

#
Show answer

JavaScript actions run directly on the runner (~2-5s startup), ideal for CI/CD logic and API calls. Docker container actions run in a container (~10-30s startup for image pull), providing environment isolation for tools like Terraform or gcc. Composite actions combine multiple steps in YAML with no packaging, ideal for reusing step patterns. Versioning: @v1 points to latest v1 (mutates), @v1.2 is a specific minor (safer), @<sha> pins to exact commit (most secure). OpenSSF Scorecard recommends SHA pinning with automated updates via renovate/dependabot. Major version branches should move with backwards-compatible releases.

Question 2Hard

How does OIDC (OpenID Connect) work in GitHub Actions for cloud authentication? Walk through setting up OIDC with AWS, including the trust policy configuration, role assumption, and how tokens are exchanged without storing static credentials as secrets.

#
Show answer

OIDC eliminates static secrets. Workflow requires id-token: write permission. AWS IAM: create an OIDC Identity Provider for token.actions.githubusercontent.com with audience sts.amazonaws.com. Create an IAM role with trust policy conditioned on "token.actions.githubusercontent.com:sub": "repo:org/repo:ref:refs/heads/main". The action aws-actions/configure-aws-credentials@v4 with role-to-assume exchanges the GitHub JWT for AWS STS temporary credentials (AccessKeyId, SecretAccessKey, SessionToken, 1-hour expiry). Claims include sub (repo), aud, environment — enabling fine-grained access control. No static secrets stored. Same pattern for GCP (workload identity federation) and Azure (azure/login with OIDC).

Question 3Medium

Differentiate between actions/upload-artifact and actions/cache. What are appropriate use cases for each? How does cache key strategy affect hit/miss rates, and what is the artifact retention policy?

#
Show answer

Artifacts persist files across runs (90 days default, configurable). Immutable — for build outputs, logs, reports. Cache stores dependencies for speed (LRU-evicted after 7 days no access). Cache key determines hit: key: ${{ runner.os }}-npm-${{ hashFiles("**/package-lock.json") }} with restore-keys fallback. Exact key match = full hit, restore-keys = partial hit (stale but usable). Use artifacts for: screenshots, test reports, compiled binaries. Use cache for: node_modules, pip, Maven .m2, Docker layers. Artifacts downloadable via UI; caches not directly visible.

Question 4Hard

Explain the different action metadata files (action.yml) and how they define inputs, outputs, runs configuration, and branding. How do you ensure backward compatibility when updating a published action?

#
Show answer

action.yml defines: name, description, inputs (with required/default), outputs, runs (using: "node20" / "docker" / "composite"), and branding (icon, color for Marketplace). Composite: runs: { using: "composite", steps: [{ run: "echo hello", shell: bash }] }. Backward compatibility: 1) Never remove or rename inputs — use deprecationMessage. 2) New inputs need defaults. 3) Outputs can be added freely. 4) Semantic versioning for breaking changes. 5) Maintain major version branches (v1, v2). 6) Migration guides in README. 7) Test with dependabot auto-merge. 8) Use @actions/core getInput() with fallbacks.

Question 5Medium

How do matrix builds work in GitHub Actions? Explain the strategy: matrix with include/exclude, dynamic matrix generation from JSON, max-parallel, fail-fast, and how you determine which job failed in a matrix.

#
Show answer

Matrix builds generate job combinations: strategy: matrix: os: [ubuntu, windows] node: [16, 18, 20]. exclude removes specific combos. include adds extra variables. Dynamic: strategy: matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}. max-parallel limits concurrency. fail-fast: true cancels all jobs on any failure. Check failure via needs.*.result or strategy context (strategy.job-index). continue-on-error: ${{ matrix.experimental }} lets experimental combos fail without blocking. Each combination is a separate job with independent status. GitHub UI groups them visually under the matrix name.

Question 6Hard

Explain GitHub Environments and deployment protection rules. How do required reviewers, deployment branches, and environment URLs work together to implement a gated deployment pipeline?

#
Show answer

Environments provide protection rules. Configured via Settings or YAML: environment: name: production url: https://app.example.com. Protection rules: 1) Required reviewers — specific users/teams must approve via GitHub UI before the job proceeds. 2) Wait timer — delays deployment (e.g., 5 minutes). 3) Deployment branches — restricts which branches can deploy (e.g., main, release/*). The environment URL appears as a link from the deployment in the GitHub UI. The job creates a pending deployment; approval pauses it until reviewers approve. Environment secrets are only accessible to jobs targeting that environment. Multiple environments (dev -> staging -> production) create a gated pipeline with increasing protection.

Question 7Medium

What are GitHub Actions workflow commands? Explain "echo ::set-output::" (deprecated), the modern echo "name=value" >> $GITHUB_OUTPUT syntax, grouping, warning/error commands, and secret masking. How do these compare to script-based output?

#
Show answer

Workflow commands communicate with the runner via stdout. Deprecated ::set-output name=value:: is replaced by echo "name=value" >> $GITHUB_OUTPUT (prevents injection). Grouping: echo "::group::name" / echo "::endgroup::". Annotations: echo "::warning file=app.js,line=1::message", echo "::error::message", echo "::notice::message". Secret masking: echo "::add-mask::value". Multi-line: { echo "key<<EOF"; echo "value"; echo "EOF"; } >> $GITHUB_OUTPUT. Environment: echo "VAR=val" >> $GITHUB_ENV. State: echo "key=val" >> $GITHUB_STATE. These are canonical over script-based approaches.

Question 8Hard

How do service containers work in GitHub Actions? Explain the container: syntax, health checks, port mapping, network connectivity between the service and job container, and how you would use Docker Compose for multi-container setups.

#
Show answer

Service containers run alongside the job: services: postgres: image: postgres:15 env: POSTGRES_PASSWORD: postgres ports: - 5432:5432 options: --health-cmd "pg_isready" --health-interval 10s --health-retries 5. Job on host connects via localhost:5432. Job in container: container: node:20, connect via postgres:5432 (service name as hostname). Health checks ensure readiness before steps run. For Docker Compose: use a step with docker compose up -d. Lifecycle: services start before steps, stop and cleaned up after job. Resources: limit via --memory. Multi-container: define multiple services with inter-service dependencies using health checks for startup ordering.

Question 9Medium

Explain the differences between reusable workflows and composite actions. What are the limitations for reusable workflows (max inputs, secrets, nested calls)? When would you choose a reusable workflow over a composite action?

#
Show answer

Reusable workflows call another .github/workflows/*.yml file. Composite actions are step collections in action.yml. Reusable limitations: max 10 inputs, max 10 secrets, max 4 nesting levels. Caller uses secrets: inherit. Composite actions have no nesting limits but cannot contain jobs — only steps. Choose reusable when: multiple jobs needed in the called unit, independent triggering (workflow_call), different runners per job, matrix strategies in called workflow. Choose composite when: reusing a step sequence, simpler context passing, no separate jobs needed.

Question 10Hard

How do you set up and secure self-hosted GitHub Actions runners? Explain runner groups, registration, labels, ephemeral runners, scaling, and security considerations like network isolation and token rotation.

#
Show answer

Register: ./config.sh --url https://github.com/org/repo --token ABC. Runner groups control repo access. Labels categorize: --labels gpu,linux. Ephemeral: --ephemeral (one job, auto-unregisters). Scaling: actions/actions-runner-controller (ARC) on Kubernetes auto-scales based on job queue. Security: 1) Never use self-hosted for public fork PRs (use pull_request_target safely). 2) Network isolation via VPC/security groups. 3) Rotate tokens via API. 4) Ephemeral runners prevent state persistence. 5) Audit via audit log. 6) Labels direct sensitive workloads. 7) Regular updates with ./svc.sh stop && ./svc.sh start. 8) GITHUB_TOKEN has limited scope for fork PRs.

Question 11Medium

How do job status functions (success(), failure(), always(), cancelled()) work in if conditions? How does continue-on-error differ from if: ${{ always() }}? Provide examples of post-job cleanup that runs regardless of failure.

#
Show answer

success() = all previous jobs/steps succeeded. failure() = any failed. always() = runs regardless. cancelled() = workflow cancelled. continue-on-error: true prevents a step from failing the job — subsequent steps still run. if: ${{ always() }} runs even after failure but you must handle potential upstream failures. Cleanup: - name: Cleanup if: ${{ always() }} run: docker compose down. Notification: if: ${{ failure() }} run: curl -X POST ${{ secrets.SLACK_WEBHOOK }}. Cancellation: if: ${{ cancelled() }}. Combined: if: ${{ success() || failure() }} runs on success or failure but not cancellation.

Question 12Hard

Explain the needs and job dependency graph in GitHub Actions. How do you share outputs between jobs, handle matrix dependencies, and manage sequential vs parallel execution with dynamic dependencies based on conditions?

#
Show answer

needs establishes job dependencies: test: needs: build. Output sharing: build step sets id: version with echo "version=1.0" >> $GITHUB_OUTPUT, then job declares outputs: version: ${{ steps.version.outputs.version }}. Dependent job accesses: ${{ needs.build.outputs.version }}. Matrix dependencies: dependent job runs once after all matrix combinations complete. Per-matrix dependency: create a second matrix. Dynamic dependencies: needs: ${{ fromJSON(needs.check.outputs.jobs) }}. Branching: build -> (deploy-staging, test-e2e) — runs in parallel after build. Sequential: deploy-prod: needs: deploy-staging. Conditional: if: ${{ needs.build.result == "success" }}.

Question 13Medium

List and explain the most important GitHub Actions contexts: github, env, vars, secrets, runner, and strategy. How do you access context values in if conditions and steps?

#
Show answer

github: github.sha, github.ref, github.actor, github.event, github.repository, github.run_id, github.workflow. env: environment variables set at workflow/job/step level. vars: configuration variables from Settings (typed, separate from secrets). secrets: encrypted secrets (redacted in logs). runner: runner.os, runner.temp, runner.tool_cache, runner.workspace, runner.arch. strategy: strategy.job-index, strategy.job-total, strategy.fail-fast. Access: ${{ github.sha }}, ${{ env.MY_VAR }}, ${{ vars.DEPLOY_HOST }}, ${{ secrets.API_TOKEN }}, ${{ runner.os }}, ${{ strategy.job-index }}. In if: if: ${{ github.ref == "refs/heads/main" }}.

Question 14Hard

How do workflow_dispatch and repository_dispatch events work? Explain input types, event payloads, client_payload for repository_dispatch, and how to trigger cross-repo workflows. Show an example of a workflow_dispatch with choice and boolean inputs.

#
Show answer

workflow_dispatch: on: workflow_dispatch: inputs: environment: description: "Deploy target" required: true type: choice options: [dev, staging, production] debug: type: boolean default: false. Trigger via UI or API: gh workflow run workflow.yml -f environment=production. repository_dispatch: on: repository_dispatch: types: [deploy]. Trigger: curl -X POST -H "Authorization: token $GH_TOKEN" https://api.github.com/repos/owner/repo/dispatches -d '{"event_type": "deploy", "client_payload": {"env": "production"}}'. Access: ${{ github.event.client_payload.env }}. Cross-repo: use a PAT to call API on another repo, or use peter-evans/repository-dispatch action with token and client_payload.

Question 15Medium

How do you implement dependency caching strategies in GitHub Actions for different ecosystems? Explain npm, pip, and Maven caching, including cache key strategies and how cache action eviction works.

#
Show answer

npm: actions/cache with path: ~/.npm, key: ${{ runner.os }}-npm-${{ hashFiles("**/package-lock.json") }}, restore-keys: ${{ runner.os }}-npm-. Pip: path: ~/.cache/pip, key: ${{ runner.os }}-pip-${{ hashFiles("**/requirements.txt") }}. Maven: path: ~/.m2, key: ${{ runner.os }}-m2-${{ hashFiles("**/pom.xml") }}. For Docker: use Docker layer caching with docker/build-push-action@v5 with cache-from/cache-to. Cache eviction: LRU after 7 days no access. Cache size limit: ~10GB per repo. Use restore-keys for partial matches when exact key misses. For monorepos, include the subdirectory path in the key to avoid collisions.

Question 16Hard

What are the security best practices for GitHub Actions? Explain minimum GITHUB_TOKEN permissions, third-party action pinning, OpenSSF Scorecard, and how to automate action updates with renovate or dependabot.

#
Show answer

Minimum GITHUB_TOKEN permissions: set in workflow top-level: permissions: contents: read issues: write. Never use write-all. Pin third-party actions to full commit SHA: uses: actions/checkout@<full-sha> instead of @v4. Use OpenSSF Scorecard to audit supply chain security. Automate updates with renovate (configure regex managers for actions) or dependabot (built-in, configured in dependabot.yml with open-pull-requests-limit). Verify SHA signatures for actions from verified creators. For forks: use pull_request_target with explicit checkout of PR code to avoid token leakage. Never store secrets in workflow files. Audit workflow run logs for accidental secret exposure. Use OIDC instead of static credentials.

Question 17Medium

How do the concurrency and cancel-in-progress settings work in GitHub Actions? Provide examples of canceling redundant workflow runs and managing environment-specific concurrency groups.

#
Show answer

Concurrency groups prevent multiple workflow runs from running simultaneously: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true. This cancels the previous run on the same branch when a new push occurs. For environments: concurrency: group: production-deploy cancel-in-progress: true prevents overlapping deployments. For staged deployments: concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.environment }}. Without cancel-in-progress, new runs wait for the previous run to complete. Use for: CI on PRs (only latest matters), production deployments (prevent concurrent deploys). The concurrency group name is arbitrary; runs with the same group name are serialized.

Question 18Hard

How would you implement a multi-stage CI/CD pipeline in GitHub Actions with build, test, staging deploy, E2E tests, and production deploy, using environments, artifact sharing, and conditional approvals?

#
Show answer

Structure: jobs: build: steps: - run: npm build && npm test - uses: actions/upload-artifact@v4 with: name: build. deploy-staging: needs: build environment: name: staging url: ${{ vars.STAGING_URL }} steps: - uses: actions/download-artifact@v4 with: name: build - run: deploy-to-staging.sh. e2e-tests: needs: deploy-staging runs-on: ubuntu-latest steps: - run: npx playwright test. deploy-prod: needs: e2e-tests environment: name: production url: https://example.com steps: - run: deploy-to-production.sh. Environments with required reviewers pause deploy-prod until approval. Artifacts pass build outputs between jobs. Use vars for environment-specific URLs and hosts. OIDC for cloud auth without static secrets.

Question 19Medium

How do you use GitHub Actions with GitHub Pages deployment? Explain the actions/deploy-pages action, artifact preparation with actions/upload-pages-artifact, and how branch-based deployment works with the actions-helped deployment workflow.

#
Show answer

For GitHub Pages, use actions/deploy-pages. Steps: 1) Build static site. 2) actions/upload-pages-artifact@v3 with path: ./dist. 3) actions/deploy-pages@v4. Requires permissions: pages: write, id-token: write. Configure Pages in repo Settings to use GitHub Actions as the source (not the legacy branch-based). The environment is automatically set to github-pages with URL. For custom domains, add a CNAME file in the static output or configure in Settings. Branch-based deployment (legacy): push to gh-pages branch. The modern approach uses the Actions workflow with explicit artifact upload and deployment steps.

Question 20Hard

Explain GitHub Actions' approach to handling pull requests from forks. How does pull_request_target differ from pull_request? What are the security implications of GITHUB_TOKEN in fork contexts, and how do you safely run CI on PRs from external contributors?

#
Show answer

pull_request (default) runs with a limited GITHUB_TOKEN that cannot access secrets — safe for forks but can't write back. pull_request_target runs in the context of the base branch (has full token access including secrets), enabling label assignment, comment creation, and artifact upload for fork PRs. Security risk: an attacker can modify a fork PR's workflow to exfiltrate secrets. Safely use pull_request_target: checkout the PR code explicitly (not the base branch), validate inputs, and never run untrusted build steps with secrets. Use paths-filter to run only on safe changes. For artifact upload from forks, use pull_request_target with explicit checkout and separate upload steps. GitHub automatically masks secrets in PR comments. Use the github.event.pull_request.head.sha for checkout.

Question 21Medium

Your GitHub Actions workflow takes 25 minutes because it builds a Docker image from scratch on every push. Design a caching strategy to reduce build time under 5 minutes, including exact cache keys and action configurations.

#
Show answer

Use Docker layer caching with docker/build-push-action@v5 and GitHub Actions cache backend: cache-from: type=gha; cache-to: type=gha,mode=max. The mode=max caches all layers (not just exported). Cache key strategy: the action automatically uses the image's manifest digest as the primary cache key with a fallback to the image name. For more granularity: cache-from: type=gha,scope=${{ github.ref }}; cache-to: type=gha,scope=${{ github.ref }},mode=max scopes cache per branch. For monorepos: use cache-from pointing to the main branch cache as restore key so feature branches can reuse the latest main cache. Additional speed-ups: (1) Order Dockerfile layers wisely — install OS packages (apt-get) before copying source (least-changing first). (2) Use --target build-stage to cache build stages separately. (3) Use a Docker layer cache action like actions/cache for /var/lib/docker manually, but type=gha is now the recommended approach. (4) For npm/pip installs, cache those separately with actions/cache keyed on lockfile hash. Combined, these changes typically bring builds from 25 min to 2-3 min for most web app Dockerfiles.

Question 22Hard

A developer pushes a commit that hardcodes an API key. Design a GitHub Actions workflow that automatically detects and blocks secrets before they reach the main branch, including the tools, actions, and failure behavior.

#
Show answer

Use trufflehog or gitLeaks in a PR workflow: on: pull_request. Steps: (1) Checkout with fetch-depth: 0 to scan full history. (2) Run trufflehog filesystem --fail --json . > trufflehog-report.json. (3) If secrets found, post a PR comment summarizing the findings and fail the workflow: if: failure() && github.event_name == 'pull_request' — use actions/github-script@v7 to comment on the PR: github.rest.issues.createComment({issue_number: context.issue.number, body: '⚠️ Secret detected in PR. Please remove before merging.'}). (4) For true secrets in history, use trufflehog git --since-commit HEAD~1 --fail to scan the diff only. (5) For pre-commit prevention, use a pre-commit hook with detect-secrets or gitleaks — but hooks can be bypassed. Server-side enforcement is essential. (6) Use GitHub's built-in secret scanning (push protection) — enable in repo Settings > Code security > Secret scanning > Push protection. This blocks pushes containing known patterns (AWS keys, GitHub tokens, etc.) at the API level. (7) For custom patterns, use trufflehog with custom regex rules. (8) Alerting: if a secret reaches main despite protection, use a pull_request_target workflow with repository write access to invalidate the secret or notify security. Failure behavior: block the merge with required status check — set branch protection rule requiring the secret-scan check to pass.

Question 23Medium

Your monorepo has 10 microservices in separate directories. Each service should only build/deploy when its directory changes. How do you implement this with path filtering and dynamic matrix generation?

#
Show answer

Use dorny/paths-filter@v3 to detect which directories changed: changes: outputs: service-a: ${{ steps.filter.outputs.service-a }}; service-b: ${{ steps.filter.outputs.service-b }}. Then generate a dynamic matrix: strategy: matrix: service: ${{ fromJSON(steps.filter.outputs.changed) }}. The paths-filter action outputs a changes JSON with the changed services. The matrix then runs only for those services. Alternative: use tj-actions/changed-files@v44 to get the list of modified files, then extract unique service directories with a shell step: services=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | grep -oP "^services/\K[^/]+" | sort -u | jq -R -s -c 'split("\n")[:-1]'). Then strategy: matrix: service: ${{ fromJSON(services) }}. For CI/CD: each service matrix entry runs build-and-deploy-${{ matrix.service }} with if: ${{ contains(needs.setup.outputs.services, matrix.service) }}. This ensures zero wasted build time — unchanged services skip entirely. For dependent services (e.g., service-b depends on service-a), add explicit needs or use a dependency graph in the workflow.

Question 24MediumSupply chain

After the tj-actions/changed-files compromise, how do you harden third-party actions?

#

Your workflows use thirty marketplace actions referenced by tags like @v4.

Show answer

In March 2025 an attacker repointed tags of the popular tj-actions/changed-files action to a malicious commit that printed CI secrets into build logs, so every workflow using a tag ran it. Tags are mutable.

Pin actions to full commit SHAs with the version in a comment, and let Dependabot or Renovate propose updates you review. GitHub now offers a policy to require full-SHA pinning and to block specific actions at the repository or organization level. Combine it with an allowlist, minimal GITHUB_TOKEN permissions, and secrets scoped to the jobs that need them.

Trade-offs

SHA pins are safe but tedious to update by hand, so automate the update pull requests.

Common mistake

Pinning the top-level action while it pulls other actions by tag internally.

Follow-up

How would you find every workflow in your organization that still uses tag references?

Pin by full commit SHA · yaml
steps:
  - uses: actions/checkout@<40-char-commit-sha> # vX.Y.Z
Question 25MediumCost

Your GitHub Actions bill doubled in a quarter. How do you cut it without slowing developers?

#

Every push runs a full matrix on large runners, and some hung jobs run for hours.

Show answer

Start with usage data per repository, workflow and runner type to find the top consumers. Common fixes: set timeout-minutes on jobs, since the default is very long and hung jobs burn minutes; use concurrency with cancel-in-progress so superseded pushes stop; cache dependencies; and run expensive matrices only on main or before merge rather than on every push.

Right-size runners: larger runners cost more per minute and only pay off for parallel work. Skip work that does not apply to a change, with care for required checks, and move rare, heavy jobs to schedules.

Trade-offs

Running less on every push saves money but finds some failures later; keep the fast checks developers need.

Common mistake

Moving everything to bigger runners hoping faster jobs will cost less.

Follow-up

Which metric would you show teams so they see the cost of their workflows?

Question 26MediumSupply chain

How do you prove a binary or image was built by your workflow and not on someone's laptop?

#

A customer asks for evidence of where your release artifacts came from.

Show answer

Generate a build provenance attestation in the workflow that produces the artifact, for example with actions/attest-build-provenance. It creates a signed statement linking the artifact's digest to the repository, workflow, commit and run that built it. The job needs id-token: write and attestations: write permissions.

Consumers verify it with gh attestation verify <artifact> --repo owner/repo or with policy tools at deploy time, and reject artifacts without a valid attestation. Attestations prove where something was built, not that the code is safe, so keep code review and scanning.

Trade-offs

Provenance adds a verification step to deployments but turns "trust us" into something customers can check.

Common mistake

Generating attestations that no deployment step ever verifies.

Follow-up

Where in your deployment path would you verify the attestation?

Question 27MediumWorkflows

You added path filters to save CI minutes. Now some pull requests can never merge. Why?

#

Docs-only pull requests show a required check stuck at "Expected — Waiting for status to be reported".

Show answer

When a workflow is skipped because its path filter does not match, its checks never report. If one of those checks is required by branch protection or a ruleset, GitHub keeps waiting for it and the pull request cannot merge.

Fixes: make the required check a small job that always runs and decides inside the workflow whether real work is needed, for example with a changed-files step and job-level conditions, since skipped jobs report as successful; or require an aggregate "all checks passed" job that depends on the others. Avoid making path-filtered workflows required directly.

Trade-offs

Filtering inside the workflow costs a few seconds per run but keeps required checks reliable.

Common mistake

Removing the check from branch protection to unblock merges.

Follow-up

How would you design one required status for a monorepo with ten services?

Question 28HardSecurity

What is the difference between pull_request and pull_request_target, and why does it matter for security?

#

A contributor from a fork opens a PR. The team wants tests to run and a bot to comment on the result.

Show answer

pull_request runs the workflow file from the PR merge commit. For a fork PR that file and code are contributor-controlled, but GitHub withholds secrets and gives only a read-only GITHUB_TOKEN; actions/checkout defaults to the merge ref. That makes it the right place to build and test untrusted code.

pull_request_target runs the workflow from the base repository default branch, with the base token and repository secrets. By default it checks out the base branch too — no fork code runs. The "pwn request" happens when you override that default: check out github.event.pull_request.head.sha, fetch the fork, or consume a fork artifact and then run npm install, tests or a build. Attacker-controlled code now holds your secrets.

Keep untrusted execution in pull_request. If a privileged step must react to a PR, split it into a separate workflow_run that treats artifacts as untrusted data, set least-privilege permissions: and scope caches so a privileged job cannot poison a later build.

Trade-offs

A single workflow that both builds and comments is convenient but forces a choice between no secrets and a pwn request.

Common mistake

Switching to pull_request_target just to make secrets available in fork PRs.

Follow-up

Why does pull_request not run on merge conflicts while pull_request_target does?

Question 29MediumTroubleshooting

A secret is empty in a workflow run from a fork. Why, and what are safe options?

#

A pull_request workflow from an outside contributor logs an empty cloud credential, while the same workflow works on branch PRs.

Show answer

Except for GITHUB_TOKEN, GitHub does not pass repository secrets to a workflow triggered from a fork. Dependabot PRs are treated the same way, and the fork PR token is read-only. That is why the value is empty rather than misspelled.

Do not "fix" it by moving the job to pull_request_target: that grants the base repository token and secrets, and running fork code there is the pwn request pattern. Keep untrusted builds in pull_request without secrets. For cloud access, use OIDC to exchange a short-lived, per-job identity token whose claims (including environment, if you use one) are scoped in the provider trust policy, so there is no long-lived cloud secret to leak.

If a step genuinely needs privileged access, put it in a separate workflow_run that consumes artifacts as untrusted data, restrict permissions:, and gate secrets behind an environment with required reviewers. Avoid self-hosted runners for public-repo PRs.

Trade-offs

OIDC removes stored credentials but pushes the security decision into claim matching in the cloud trust policy.

Common mistake

Grabbing secrets from the base repository in a pull_request_target job that checks out the fork.

Follow-up

How would you scope an OIDC trust policy so only the deploy environment can assume the role?

Question 30MediumDelivery

What are the DORA metrics and how do you measure them?

#

Leadership wants one dashboard to compare delivery performance across twelve teams.

Show answer

DORA now defines five software delivery performance metrics. Throughput: change lead time (commit to production), deployment frequency (deployments per period, or time between them). Instability: change fail rate (deployments needing a rollback, hotfix or fix), failed deployment recovery time (recovery from a deployment that needs immediate intervention), and deployment rework rate (unplanned deployments caused by a production incident, added in 2024). The old label MTTR was replaced in 2023 because it mixed change-caused failures with unrelated outages.

Measure them per application or service from data you already have: deployment events from the pipeline, commit timestamps, rollback or hotfix records and incident timelines. Avoid blending numbers across teams with different release models.

DORA explicitly warns against setting the metrics as targets: once people optimise for the number, deployment frequency and lead time stop measuring what you intended.

Trade-offs

Per-service metrics are more honest but harder to roll into a single executive number.

Common mistake

Quoting four metrics, calling the recovery metric MTTR, or averaging all teams into one score.

Follow-up

Why can a higher deployment frequency still hide a worsening change fail rate?