Generate a GitHub Actions QA Pipeline with AI
Returns a complete `.github/workflows/qa.yml` with unit → integration → E2E stages, Playwright browser matrix, dependency + browser caching keyed on lockfile, artifact retention with explicit period, and failure notification via webhook / Slack.
When to use it
- Bootstrapping a QA pipeline for a new project.
- Migrating from Jenkins or CircleCI to GitHub Actions.
- Auditing an existing pipeline for missing best practices (cache, artifacts, notifications).
- Standardizing pipelines across multiple repos.
The prompt
<role>You are a CI/CD specialist who has shipped QA pipelines for large monorepos. You pin runner versions to lockfile hashes (not 'latest'), externalize secrets via OIDC where possible, and treat test artifacts as evidence: retained for at least 7 days.</role> <context>GitHub Actions best practices for QA pipelines (2026):- **Cache** keyed on lockfile hash for npm + Playwright browsers- **Concurrency** group per PR to cancel stale runs- **Permissions** scoped to least-privilege (no `contents: write` unless needed)- **OIDC** instead of long-lived secrets where supported- **Artifacts** for test reports + traces with explicit retention- **Notifications** on failure to relevant channel (Slack, webhook)- **Matrix** for cross-browser / cross-OS testing</context> <task>Generate a `.github/workflows/qa.yml` with:1. Triggers on PR + push to main2. Concurrency group cancellable per PR3. Permissions scoped minimally4. Jobs: install (with cache) → lint → unit → integration → e2e5. Playwright browser matrix (chromium, firefox, webkit)6. Cache for npm and Playwright browsers, keyed on package-lock.json7. Test report + trace artifacts with 7-day retention8. Failure notification step (Slack incoming webhook or repository_dispatch)9. Skip e2e on doc-only PRs (paths-ignore)</task> <input>Tech stack: {stack}Test frameworks: {frameworks}Notification target (Slack, Teams, custom webhook): {notification}Special requirements (monorepo, multiple apps, etc.): {special}</input> <constraints>- Pin action versions to commit SHA OR major version (`@v4`), not `@latest`.- Cache keys MUST include lockfile hash for invalidation.- Artifacts MUST have explicit retention-days (not default 90).- Failure notification MUST gate on `if: failure()`.- Use `fail-fast: false` for E2E matrix so a Firefox failure doesn't kill Chromium run.- Concurrency group + cancel-in-progress for PR efficiency.</constraints> <output_format>Complete YAML file in a code block. Followed by a "What this gives you" section with bullets on cost, runtime, and what's NOT covered.</output_format> <approach>Before writing, identify the project's lockfile (package-lock.json, yarn.lock, pnpm-lock.yaml): caching depends on it.</approach>## RoleCI/CD specialist. Pin versions to lockfile hashes, OIDC over long-lived secrets, artifacts as evidence (7+ day retention). ## ContextGitHub Actions QA best practices (2026):- Cache keyed on lockfile hash (npm + Playwright browsers)- Concurrency group per PR (cancel stale)- Permissions least-privilege- OIDC over secrets when supported- Artifacts with explicit retention- Failure notifications- Matrix for cross-browser/cross-OS ## TaskGenerate `.github/workflows/qa.yml` with:1. Triggers (PR + push to main)2. Concurrency group cancellable per PR3. Permissions scoped minimally4. Jobs: install (cache) → lint → unit → integration → e2e5. Playwright matrix (chromium, firefox, webkit)6. Cache for npm + Playwright browsers (lockfile-keyed)7. Test reports + traces (7-day retention)8. Failure notification (Slack webhook or repository_dispatch)9. Skip e2e on doc-only PRs (paths-ignore) ## Input- Stack: {stack}- Test frameworks: {frameworks}- Notification target: {notification}- Special requirements: {special} ## Constraints- Pin action versions (@v4 or SHA, not @latest).- Cache keys include lockfile hash.- Artifacts explicit retention-days.- Failure notification `if: failure()`.- E2E matrix uses `fail-fast: false`.- Concurrency group + cancel-in-progress. ## Output formatYAML code block + "What this gives you" bullets (cost, runtime, what's NOT covered). ## ApproachIdentify project's lockfile first.Example
Input
Tech stack: Next.js 15 + Node.js 24 LTS + TypeScript. Monorepo with apps/web and apps/api. Test frameworks: Vitest (unit + integration), Playwright (E2E). Notification target: Slack via incoming webhook. Special requirements: monorepo (only build affected workspaces); skip E2E on doc-only PRs.
Output
```yaml
# .github/workflows/qa.yml
name: QA Pipeline
on:
pull_request:
branches: [main]
paths-ignore:
- 'docs/**'
- '**.md'
push:
branches: [main]
concurrency:
group: qa-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
pull-requests: write
checks: write
env:
NODE_VERSION: '24'
CACHE_PATH_PLAYWRIGHT: ~/.cache/ms-playwright
jobs:
changes:
name: Detect affected workspaces
runs-on: ubuntu-latest
outputs:
workspaces: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
web: ['apps/web/**', 'package-lock.json']
api: ['apps/api/**', 'package-lock.json']
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci --prefer-offline --no-audit --no-fund
- run: npm run lint
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci --prefer-offline --no-audit --no-fund
- run: npm run typecheck
unit-integration:
name: Unit + Integration (${{ matrix.workspace }})
needs: changes
if: needs.changes.outputs.workspaces != '[]'
runs-on: ubuntu-latest
strategy:
matrix:
# Only the workspaces touched by this change (all of them on push to main if both changed)
workspace: ${{ fromJSON(needs.changes.outputs.workspaces) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci --prefer-offline --no-audit --no-fund
- run: npm run test:unit -- --coverage
working-directory: apps/${{ matrix.workspace }}
- name: Upload coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.workspace }}
path: apps/${{ matrix.workspace }}/coverage
retention-days: 7
e2e:
name: E2E (${{ matrix.browser }})
needs: [lint, typecheck]
runs-on: ubuntu-latest
strategy:
matrix:
browser: [chromium, firefox, webkit]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- run: npm ci --prefer-offline --no-audit --no-fund
- name: Cache Playwright browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: ${{ env.CACHE_PATH_PLAYWRIGHT }}
# One cache per browser: a shared key would restore chromium-only into the firefox/webkit jobs
key: playwright-${{ runner.os }}-${{ matrix.browser }}-${{ hashFiles('package-lock.json') }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps ${{ matrix.browser }}
- name: Install browser OS dependencies (not cached)
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps ${{ matrix.browser }}
- run: npx playwright test --project=${{ matrix.browser }}
env:
BASE_URL: ${{ secrets.STAGING_BASE_URL }}
- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report-${{ matrix.browser }}
path: playwright-report/
retention-days: 7
- name: Upload Playwright traces
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-traces-${{ matrix.browser }}
path: test-results/
retention-days: 7
notify-on-failure:
name: Notify Slack on failure
needs: [lint, typecheck, unit-integration, e2e]
if: failure() && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Send Slack notification
uses: slackapi/slack-github-action@v2
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"text": "QA pipeline failed on main",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*QA pipeline failed* on `${{ github.ref_name }}`\nCommit: ${{ github.sha }}\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View run>"
}
}
]
}
```
## What this gives you
- **Runtime**: ~6-10 min on a clean PR with cache miss; ~3-5 min with cache hit. E2E matrix runs 3 browsers in parallel, ~8-12 min for E2E alone.
- **Cost**: GitHub Actions free tier covers ~2000 minutes/month for private repos. Heavy E2E usage (multiple browsers × multiple PRs/day) often blows past this: budget accordingly or use self-hosted runners.
- **Cache invalidation**: triggered by changes to package-lock.json (npm cache and the per-browser Playwright cache). OS packages are never cached, so cache hits still run `playwright install-deps`.
- **Affected workspaces only**: `dorny/paths-filter` feeds the unit/integration matrix, so a PR touching only `apps/api` never runs the web tests.
- **NOT covered**:
- Performance / load tests: separate workflow recommended.
- Visual regression tests: add as a new job + use Playwright `toHaveScreenshot`.
- Mobile testing: use BrowserStack / Sauce Labs via additional jobs.
- Cross-OS matrix: currently Linux only; add macOS / Windows as needed for native code.
- **Skip on docs**: `paths-ignore` skips the whole workflow on doc-only PRs. If these jobs are required status checks in branch protection, a skipped workflow leaves the PR waiting forever: either don't mark them required, or replace `paths-ignore` with a paths-filter output that skips only the E2E job.Common pitfalls
- Action versions pinned to '@latest': breaks reproducibility. Force semver or SHA.
- Artifacts use default 90-day retention: generates noise + cost. Force explicit retention-days.
- fail-fast omitted on E2E matrix: Firefox failure cancels chromium and webkit. Always set fail-fast: false.
- Notification step runs on success too: only fire on failure with `if: failure()`.
Tips
- Use OIDC for cloud deploys (no long-lived AWS access keys). Read GitHub's OIDC docs.
- Use reusable workflows (`uses: ./.github/workflows/reusable.yml`) for multi-repo orgs.
- Add a `merge_group` trigger for merge queues: same workflow runs at queue time.
- Pair with `parallel-test-execution-config` for sharding when E2E suite grows.
FAQ
How do I optimize cost?
Cancel stale PR runs via concurrency. Use cache keys aggressively. Run E2E only on PRs touching code (paths-ignore for docs). Consider self-hosted runners for high-volume workflows. Move heavy load tests to a separate weekly schedule.
When to fan out vs serialize jobs?
Fan out when jobs are independent (lint, typecheck, unit, e2e per browser). Serialize when jobs depend on artifacts from earlier jobs (deploy after test). Use `needs:` to express dependencies explicitly.
Reusable workflows vs composite actions?
Reusable workflows for entire CI pipelines shared across repos. Composite actions for reusable steps within a workflow (e.g., 'setup node and install deps'). Use composite actions liberally; reusable workflows for org-wide patterns.
OIDC vs long-lived secrets?
OIDC is short-lived, scoped to specific repos/branches, and auditable. Long-lived secrets are easier to set up but leak more often. Use OIDC for any cloud-provider integration; secrets only for things without OIDC support.