Skip to content

workflow_run event with types:[completed] triggers before workflow actually completes #4035

@amalc

Description

@amalc

Bug Description

The workflow_run event with types: [completed] is incorrectly triggering BEFORE the referenced workflow actually completes, in addition to the correct trigger after completion.

Expected Behavior

According to GitHub Actions documentation, workflow_run with types: [completed] should only trigger AFTER the referenced workflow finishes running.

Actual Behavior

The workflow_run event triggers TWICE:

  1. Once immediately after the referenced workflow starts (incorrect)
  2. Once after the referenced workflow completes (correct)

Reproduction Steps

  1. Create a workflow that triggers on workflow_run:
name: Deploy
on:
  workflow_run:
    workflows: ["CI/CD Pipeline"]
    types: [completed]
    branches: [develop]
  1. Push code to trigger the CI/CD Pipeline workflow
  2. Observe that the Deploy workflow triggers immediately (within seconds) while CI is still running
  3. The Deploy workflow correctly skips because github.event.workflow_run.conclusion is not 'success'
  4. Several minutes later, when CI completes, the Deploy workflow triggers again (correctly)

Evidence

Repository: amalc/launcher

Example sequence on 2025-09-10:

  • CI/CD Pipeline started at 22:57:02 UTC (run ID: 17628907096)
  • Deploy workflow triggered at 22:57:14 UTC (run ID: 17628910540) - INCORRECT, CI still running, correctly skipped
  • CI/CD Pipeline completed successfully ~6 minutes later
  • Deploy workflow triggered again at 23:03:57 UTC (run ID: 17629021343) - CORRECT, after CI completed

Impact

  • Creates confusing "skipped" workflow runs in the Actions tab
  • Wastes GitHub Actions minutes checking conditions unnecessarily
  • Makes debugging deployment issues more difficult
  • Could cause race conditions if the condition check is not properly implemented
  • Clutters the Actions history with duplicate runs

Current Workaround

We check github.event.workflow_run.conclusion == 'success' which correctly skips premature triggers, but this shouldn't be necessary if the event only fired after completion as documented.

Environment

  • Repository type: Public repository
  • Workflow trigger: workflow_run with types: [completed]
  • Affected branches: All branches specified in workflow_run trigger
  • Runner: GitHub-hosted runners

Related Issues

This may be related to event queuing or race conditions in the GitHub Actions event dispatcher.

Please fix the workflow_run event to only trigger after the referenced workflow actually completes, matching the documented behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions