Skip to content

docs: fix custom trigger filtering — replace exit 1 with job-based graceful skip#21215

Merged
pelikhan merged 2 commits intomainfrom
copilot/allow-conditional-trigger-filtering
Mar 16, 2026
Merged

docs: fix custom trigger filtering — replace exit 1 with job-based graceful skip#21215
pelikhan merged 2 commits intomainfrom
copilot/allow-conditional-trigger-filtering

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

Using exit 1 in a pre-agent step to filter triggers marks the entire workflow run as failed, cluttering the Actions tab with red X's and spuriously firing the Workflow Failure issue mechanism.

Changes

  • Job-based filter pattern (primary): Replace the exit 1 step anti-pattern with a deterministic filter job that sets a boolean output and never exits non-zero. The if: frontmatter field references the output; the compiler wires the filter job as a dependency of activation so non-matching runs are skipped, not failed.
jobs:
  filter:
    runs-on: ubuntu-latest
    outputs:
      should-run: ${{ steps.check.outputs.result }}
    steps:
      - id: check
        env:
          LABELS: ${{ toJSON(github.event.issue.labels.*.name) }}
        run: |
          if echo "$LABELS" | grep -q '"bug"'; then
            echo "result=true" >> "$GITHUB_OUTPUT"
          else
            echo "result=false" >> "$GITHUB_OUTPUT"
          fi

if: needs.filter.outputs.should-run == 'true'
  • Simple context conditions: Added subsection showing direct if: usage (no custom job needed) for conditions expressible from GitHub Actions context alone.
  • Query-based filtering: Added subsection pointing to skip-if-match: / skip-if-no-match: as the idiomatic mechanism when the filter can be expressed as a GitHub search query — both produce the same skipped-not-failed outcome.

Copilot AI and others added 2 commits March 16, 2026 11:39
…aceful skip pattern

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 16, 2026 12:07
Copilot AI review requested due to automatic review settings March 16, 2026 12:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the “Custom Trigger Filtering” documentation to avoid failing workflows when a trigger doesn’t match, by describing skip-based filtering patterns instead of using exit 1.

Changes:

  • Replaces the exit 1 trigger-filtering example with a job output + workflow-level if: pattern.
  • Adds a “Simple Context Conditions” subsection showing direct if: usage without a custom job.
  • Adds a “Query-Based Filtering” subsection pointing to skip-if-match / skip-if-no-match.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.


## Custom Trigger Filtering

Use a deterministic job to compute whether the agent should run, expose the result as a job output, and reference it with `if:`. The compiler automatically adds the filter job as a dependency of the activation job, so when the condition is false the workflow run is **skipped** (not failed), keeping the Actions tab clean.
@pelikhan pelikhan merged commit 1f905b5 into main Mar 16, 2026
37 checks passed
@pelikhan pelikhan deleted the copilot/allow-conditional-trigger-filtering branch March 16, 2026 12:12
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.

Allow conditional trigger filtering without failing workflow runs

3 participants