Skip to content

Fix broken automerge workflow: uncomment event triggers and declare missing dry-run input#6397

Open
Copilot wants to merge 4 commits into
masterfrom
copilot/fix-automerge-workflow-issues
Open

Fix broken automerge workflow: uncomment event triggers and declare missing dry-run input#6397
Copilot wants to merge 4 commits into
masterfrom
copilot/fix-automerge-workflow-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

  • Identify root cause: GITHUB_TOKEN is an integration token, blocked from /user API that reitermarkus/automerge@v2 requires
  • Update workflow to use a PAT secret (AUTOMERGE_TOKEN) instead of GITHUB_TOKEN
  • Add comment documenting the required repo admin steps (create PAT secret + enable branch protection)
Original prompt

The automerge workflow in .github/workflows/automerge.yml is broken due to two issues:

Issue 1: Most pull_request_target event types are commented out

Lines 22–27 have critical event types commented out:

  pull_request_target:
    types:
    #   - opened
    #   - synchronize
    #   - reopened
    #   - edited
    #   - labeled
    #   - unlabeled
      - ready_for_review

The only active trigger is ready_for_review, meaning the automerge workflow will not run when:

  • A PR is opened — won't check for the automerge label
  • A PR is labeled — adding the automerge label won't trigger a merge attempt
  • A PR is unlabeled — removing never-merge won't trigger a re-check
  • A PR is synchronized (new commits pushed) — won't re-evaluate after CI passes

Fix: Uncomment these event types so the workflow triggers on all relevant PR events:

  pull_request_target:
    types:
      - opened
      - synchronize
      - reopened
      - edited
      - labeled
      - unlabeled
      - ready_for_review

Issue 2: dry-run references an undefined workflow_dispatch input

Line 53 references github.event.inputs.dry-run but this input is never declared in the workflow_dispatch.inputs section:

          dry-run: ${{ github.event.inputs.dry-run }}

Fix: Add the dry-run input to the workflow_dispatch.inputs section:

  workflow_dispatch:
    inputs:
      pull-request:
        description: Pull Request Number
        required: false
      review:
        description: Review ID
        required: false
      dry-run:
        description: Dry Run
        required: false
        default: "false"

Full fixed file

The corrected .github/workflows/automerge.yml should be:

# https://github.com/marketplace/actions/auto-merge-pull-request
name: Automerge

on:
  # Try enabling auto-merge for all open pull requests.
  schedule:
    - cron: "30 1 * * *"

  # Try enabling auto-merge when a pull request is approved. Note that this
  # event skips the check for the pull request author association and instead
  # checks the review author association.
  pull_request_review:
    types:
      - submitted

  # Try enabling auto-merge for a pull request when a draft is marked as
  # "ready for review", when a required label is applied or when a
  # "do not merge" label is removed, or when a pull request is updated in
  # any way (opened, synchronized, reopened, edited).
  pull_request_target:
    types:
      - opened
      - synchronize
      - reopened
      - edited
      - labeled
      - unlabeled
      - ready_for_review

  # Try enabling auto-merge for the specified pull request,
  # review or all open pull requests if none is specified.
  workflow_dispatch:
    inputs:
      pull-request:
        description: Pull Request Number
        required: false
      review:
        description: Review ID
        required: false
      dry-run:
        description: Dry Run
        required: false
        default: "false"

jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
      - uses: reitermarkus/automerge@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          merge-method: rebase
          do-not-merge-labels: never-merge
          required-labels: automerge
          pull-request: ${{ github.event.inputs.pull-request }}
          review: ${{ github.event.inputs.review }}
          dry-run: ${{ github.event.inputs.dry-run }}

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: why automerge is broken?

Assistant: Based on my analysis of the automerge workflow in espnet/espnet, here are the issues causing it to be broken:

Root Causes

1. 🔴 Most pull_request_target event types are commented out (Lines 22–27)

  pull_request_target:
    types:
    #   - opened
    #   - synchronize
    #   - reopened
    #   - edited
    #   - labeled
    #   - unlabeled
      - ready_for_review

The only active trigger is ready_for_review, meaning the automerge workflow will not run when:

  • A PR is opened — won't check for the automerge label
  • A PR is labeled — adding the automerge label won't trigger a merge attempt
  • A PR is unlabeled — removing never-merge won't trigger a re-check
  • A PR is synchronized (new commits pushed) — won't re-evaluate after CI passes

This is the most likely reason automerge appears broken — even if you add the automerge label, nothing happens because the labeled event is commented out.

2. 🟡 dry-run references an undefined input (Line 53)

          dry-ru...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/espnet/espnet/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

@mergify mergify Bot added the CI Travis, Circle CI, etc label Mar 27, 2026
Copilot AI changed the title [WIP] Fix automerge workflow by uncommenting event types Fix broken automerge workflow: uncomment event triggers and declare missing dry-run input Mar 27, 2026
Copilot AI requested a review from sw005320 March 27, 2026 13:20
@sw005320 sw005320 marked this pull request as ready for review March 27, 2026 13:24
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. Bugfix labels Mar 27, 2026
@Fhrozen
Copy link
Copy Markdown
Member

Fhrozen commented Mar 28, 2026

pre-commit.ci autofix

@Fhrozen Fhrozen added this to the v.202607 milestone Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix CI Travis, Circle CI, etc size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants