| description | Shared design patterns for command workflows, monitoring workflows, large-repository workflows, database migration reviews, and cross-repository operations. |
|---|
- the action is conversational
- the user may pass arguments in the comment body
- the workflow should work across issues, pull requests, and discussions
- the action is one-shot and argument-free
- discoverability in the GitHub UI matters
- the workflow fits a label-driven process
- the action is common enough to justify both invocation styles
- you want UI discoverability plus comment-based flexibility
See also: triggers.md
- monitoring another GitHub Actions workflow in the same repository
- reacting to workflow completion/conclusion
Incident-triage pattern:
- trigger:
on.workflow_runfor the named deployment/CI workflow - permissions: include
actions: read; main job read-only - reads: failed job logs/artifacts via GitHub tools
- output:
create-issuewith impact/root cause;noopwhen no action needed
Compact workflow_run examples:
- Deploy workflow failure triage: trigger on
workflow_runforDeploy, read failed jobs/logs/artifacts, create one incident issue,noopwhen rerun succeeds. - CI regression watcher: trigger on
workflow_runforCI, compare current failure against recent runs, create issue only for new regressions,noopfor known flakes.
Incident duplicate-suppression pattern:
- derive a stable incident key from the monitored workflow and failure signal (for example
<workflow-name>#<head-sha>#<failed-job-name>) - search open issues by title-prefix/label/key before creating a new issue
- create via
safe-outputs.create-issueonly when no matching open incident exists - use
noopfor duplicates and include the matching issue number in the explanation
- monitoring an external deployment service reporting back to GitHub
Rule of thumb:
workflow_run→ GitHub Actions outcomes in this repodeployment_status→ external platform outcomes via Deployments API
Single-job limits apply:
- triage, evidence collection, and summary in one agent job
- no multi-job fan-out/fan-in
- no cross-workflow waits or chaining
See also: deployment-status.md
For workflows receiving many similar events (issues, PR comments, CI failures, security alerts, dependency events):
- start with a cheap triage/classification pass
- detect known/duplicate/stale/low-value cases first
- emit
noopor a safe output when triage is confident - escalate to the main agent only when uncertain or genuinely new/high-value
Decision flow:
IF cheap triage is confident (known/duplicate/stale/low-value) THEN
emit safe output or noop
ELSE
escalate to the main agent
END IF
Use with pull-context workflows: fetch targeted evidence on demand instead of pushing raw logs into the initial prompt.
For recurring maintenance in large repos:
- use
cache-memory - process one package/module/directory per run
- store last-processed item; round-robin
- prefer small focused PRs over wide sweeps
See also: memory.md
When writing steps:, pre-steps:, and post-steps:, choose the implementation type in this order of preference:
Use actions/github-script for GitHub API interactions and general scripting. The workflow compiler handles action pinning automatically; specify a recent major version tag (@v7) without a SHA.
-
Provides typed access to the GitHub REST API via
github.rest.* -
Exposes
context,core,github,io, andexechelpers -
Eliminates shell injection risks for untrusted input
-
Example:
steps: - name: Fetch issue data uses: actions/github-script@v7 with: script: | const issue = await github.rest.issues.get({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, }); core.setOutput('title', issue.data.title);
Use run: steps when actions/github-script is not suitable. To prevent shell injection, never interpolate untrusted values directly into the script body. Any value that originates from user input — including github.event.issue.title, github.event.issue.body, github.event.comment.body, github.event.pull_request.title, github.event.pull_request.body, and github.head_ref — must be passed through environment variables:
# ❌ Unsafe: direct expression interpolation into the shell script
- name: Unsafe comment
run: gh issue comment ${{ github.event.issue.number }} --body "${{ github.event.issue.title }}"
# ✅ Safe: pass untrusted values through env vars and reference them as $VAR_NAME
- name: Safe comment
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
TITLE: ${{ github.event.issue.title }}
run: gh issue comment "$ISSUE_NUMBER" --body "$TITLE"Use Python only when the task genuinely requires data science or numeric libraries (for example pandas, numpy, matplotlib). Prefer actions/github-script or a shell step for everything else.
Use deterministic steps: when the workflow needs large external data before the agent runs.
Rules:
- write prepared files to
/tmp/gh-aw/agent/ - trim large outputs before handing to the agent
- set
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}on everyghstep - add
permissions: actions: readfor downloading workflow logs/artifacts - use
jqto reduce JSON payload size
Compact reporting/incident prefetch example:
steps:
- name: Prefetch compact failure context
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: |
gh api "repos/$REPO/actions/runs/$RUN_ID/jobs" \
--jq '[.jobs[] | select(.conclusion != "success") | {name, conclusion, started_at, completed_at}]' \
> /tmp/gh-aw/agent/failed_jobs.jsonFor PR UI validation and screenshot diffs:
- trigger:
pull_request - tools:
playwrightpluscache-memoryfor baseline metadata - permissions: read-only repo/PR access
- output:
add-commentwith pass/fail summary and artifact links - fallback:
noopwhen no UI changes detected
For PRs touching design tokens or CSS files that require a linked design reference (Figma link, design doc URL, or ADR token):
- trigger:
pull_requestwithpaths:scoped to token/style files (for exampletokens/**,**/*.tokens.json,**/*.css,src/styles/**,design-system/**) - permissions:
pull-requests: read,contents: read; agent job read-only - reads: PR body and comments via
gh pr viewto locate the linked design reference; then validate that the link target is reachable and matches the changed components - output:
- Link present and valid →
add-commentwith ✅ summary - Link present but incomplete (for example wrong component, outdated version) →
add-commentdescribing the specific gap - Required link missing →
add-commentrequesting it; escalate tocreate-issueonly when the workflow prompt explicitly requires a blocking review gate (for example a CODEOWNERS or policy rule) and no open issue already covers the same scope
- Link present and valid →
- fallback:
noopwhenpaths:guard excludes all changed files
See also: the PR Checks with Linked References pattern in github-agentic-workflows.md.
For PR QA coverage summaries (gaps, risks, suggested test focus):
- trigger:
pull_request(optionally scoped withpaths:) - tools:
github(gh-proxy) for changed files, PR metadata, labels, checks - permissions:
contents: read,pull-requests: read; agent job read-only - output:
add-commentwith coverage matrix and untested/high-risk areas - fallback:
noopfor non-testable changes (e.g. docs-only)
For recurring product/stakeholder digests:
- trigger: fuzzy
schedule(e.g.weekly on mondays) - tools:
github(gh-proxy), optionalcache-memoryfor period-over-period continuity - permissions: read-only
- output:
create-issueby default;create-discussiononly when requested - prompt: audience-aware language (summary first, details second)
For PRs adding/modifying migration files:
- trigger:
pull_requestwithpaths:scoped to migration dirs (e.g.db/migrate/**,migrations/**,*.sql) - permissions:
contents: read,pull-requests: read; agent job read-only - reads: changed migration content via GitHub tools
- output:
add-commentflagging risky operations;noopwhen clean - prompt: include migration best practices
For cross-repo reads and writes:
- enable GitHub toolsets needed for external repos
- configure PAT or GitHub App auth in
safe-outputs:for cross-repo writes - tell the agent to set
target-repoexplicitly - document required token scopes in the prompt or instructions
Cross-repo workflows inherit single-job constraints from workflow-constraints.md.