Skip to content

docs: add workflow_run trigger examples for DevOps monitoring workflows#29060

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/add-workflow-run-examples
Closed

docs: add workflow_run trigger examples for DevOps monitoring workflows#29060
Copilot wants to merge 3 commits intomainfrom
copilot/add-workflow-run-examples

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 29, 2026

workflow_run was mentioned 4 times in create-agentic-workflow.md with no complete examples, leaving DevOps monitoring scenarios (CI/CD failure detection, deployment alerting) poorly served.

Changes

  • New section: "Creating Monitoring Workflows" — added after "Creating Command Workflows" to sit alongside other trigger pattern docs
    • deployment_status vs workflow_run distinction callout
    • Context variables reference table (conclusion, id, html_url, head_branch, head_commit.message)
    • Example 1 — minimal workflow_run + if: conclusion == 'failure' that posts a PR comment; no pre-steps
    • Example 2 — full DevOps pattern: monitors multiple workflows, pre-fetches --log-failed logs, uses cache-memory for run deduplication, and instructs the agent to post a root-cause comment
    • When-to-use checklist and agent guidance for routing monitoring requests to this pattern

Example 2 frontmatter shape:

on:
  workflow_run:
    workflows: ["CI", "Deploy"]
    types: [completed]
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
permissions:
  contents: read
  actions: read        # required to download workflow run logs
tools:
  github:
    toolsets: [default]
  cache-memory: true   # deduplication: skip already-diagnosed run IDs
steps:
  - name: Fetch failed run logs
    env:
      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      RUN_ID: ${{ github.event.workflow_run.id }}
    run: |
      gh run view "$RUN_ID" --log-failed > /tmp/gh-aw/agent/ci-logs.txt 2>&1 || true
      tail -500 /tmp/gh-aw/agent/ci-logs.txt > /tmp/gh-aw/agent/ci-logs-trimmed.txt
safe-outputs:
  add-comment:
    max: 1

Copilot AI and others added 2 commits April 29, 2026 06:30
Add a new "Creating Monitoring Workflows" section to .github/aw/create-agentic-workflow.md
placed after "Creating Command Workflows". The section includes:

- Intro explaining workflow_run for GitHub Actions-internal monitoring
- Clarification on deployment_status vs workflow_run distinction
- Key context variables table (conclusion, name, id, html_url, head_branch, commit message)
- Example 1: minimal CI failure notification (no pre-steps)
- Example 2: full DevOps monitoring with log fetching, root-cause analysis, and dedup
- Guidance for when to use workflow_run vs deployment_status
- Agent guidance for responding to DevOps monitoring requests

Closes #<issue>

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/71971270-4764-4836-beee-b7c0d1e6e7bd

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Add workflow_run trigger examples to create-agentic-workflow.md docs: add workflow_run trigger examples for DevOps monitoring workflows Apr 29, 2026
Copilot AI requested a review from gh-aw-bot April 29, 2026 06:33
Copilot AI added a commit that referenced this pull request Apr 29, 2026
- Compile on.workflow_run.conclusion (string|string[]) into a job if
  condition that guards conclusion matching, guarded by event_name check
  so the condition remains transparent for other triggers (e.g. workflow_dispatch)
- Comment out the conclusion field in the YAML on: section with explanatory
  comment, tracking inWorkflowRunConclusionArray to avoid false matches on
  workflows:/types: array items
- Add workflow_run_conclusion to aw_context passed to workflow_call so
  called workflows can access the triggering run's conclusion
- Add gh-aw.workflow_run.conclusion OTEL attribute to setup and conclusion
  spans in send_otlp_span.cjs, reading from awInfo or aw_context propagation
- Add workflow_run_conclusion to generate_aw_info.cjs for direct event access
- Add "Creating Monitoring Workflows" section to create-agentic-workflow.md
  (from PR #29060), updated to use on.workflow_run.conclusion instead of
  manual if: condition
- Add unit tests: TestExtractWorkflowRunConclusionCondition,
  TestExtractIfConditionMergesWorkflowRunConclusion,
  TestWorkflowRunConclusionCommentedInYAML

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7cab4a8f-bc7a-47f5-9cc5-79d5593830fb

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Add workflow_run trigger examples to create-agentic-workflow.md

3 participants