skip to Main Content

I’m facing an issue with GitHub Actions where the workflow_dispatch event trigger, combined with the pull_request event, does not wait for manual actions and triggers automatically upon pull request opening.

Here’s a simplified version of my workflow configuration:

name: Manual Workflow on PR
on:
  pull_request:
    types:
      - opened
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      #...

According to the GitHub Actions documentation, the workflow_dispatch event should allow manual triggering of the workflow. However, in my case, the workflow always starts automatically when a new pull request is opened, regardless of manual triggering.

I have verified that the indentation of the workflow file is correct, and I have committed and pushed the latest version of the file to the repository. Despite these checks, the workflow fails to wait for manual interaction.

I would appreciate any insights or suggestions on why the workflow_dispatch event is not waiting for manual actions and how to make it trigger manually as expected.

2

Answers


  1. You have configured 2 conditions for action trigger

    on:
      pull_request:
        types:
          - opened
      workflow_dispatch:
    
    1. On pull_request Open
    2. On workflow_dispatch

    you can remove 1 so when any pull request open your workflow didn’t run automatically.

    workflow_dispatch is the keyword you need to run a GitHub Action on demand, without having to push or create a pull request.
    
    Login or Signup to reply.
  2. Workflows trigger according to the on configuration, if ANY of the informed condition is met.

    Documentation: Events that trigger workflows

    In your case with the following configuration:

    on:
      pull_request:
        types:
          - opened
      workflow_dispatch:
    

    You are actually allowing the workflow to trigger if one of two conditions is met:

    1. A Pull Request is opened: Reference

    2. The workflow is triggered manually (through the GitHub API, GitHub UI or Github CLI): Reference

    If you just want to trigger the workflow manually, you should only keep the workflow_dispatch configuration:

    on:
      workflow_dispatch:
    

    For more informations, you can also check how to manually trigger workflows on the documentation.

    Note that there is also a manual approval for deployments configuration for GitHub Actions, which requires a reviewer approval during a workflow run to continue its process.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search