Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/auto-merge-speakeasy-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Auto-merge Speakeasy PR

on:
pull_request:
types: [labeled]
types: [labeled, opened]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[blocker] opened trigger added but the job if: condition always returns false on opened events — making this trigger a no-op

Details

Why: The job's if: block ends with:

contains(fromJSON('["patch", "minor", "major"]'), github.event.label.name)

On an opened event, github.event.label is not set — github.event.label.name evaluates to an empty string "". contains(["patch","minor","major"], "") returns false in GitHub Actions expressions, so the entire if: condition short-circuits to false regardless of the other predicates. The workflow step runs (triggering a runner), but the auto-merge job is immediately skipped — the opened trigger achieves nothing.

According to the GitHub docs, when Speakeasy opens a PR and immediately applies a label via the API, GitHub fires both pull_request.opened AND pull_request.labeled events. So the original labeled-only trigger should already be sufficient if the label is applied before or shortly after PR creation. If there is a race condition where the workflow is not yet registered by the time the labeled event fires (e.g. the repo was empty), the right fix is to add a label check that works for opened too — not just adding the trigger.

Fix options:

  1. Remove the opened trigger (revert this hunk) if labeled reliably fires for Speakeasy PRs — the bot-username fix on lines 21–22 is still correct and useful.
  2. If a race condition is confirmed, restructure the if: to branch on event type:
if: |
  (github.event.sender.login == 'app/github-actions') &&
  (github.event.pull_request.user.login == 'app/github-actions') &&
  startsWith(github.event.pull_request.head.ref, 'speakeasy-sdk-regen-') &&
  contains(github.event.pull_request.title, '🐝 Update SDK') &&
  (
    (github.event_name == 'pull_request' && github.event.action == 'labeled' &&
     contains(fromJSON('["patch", "minor", "major"]'), github.event.label.name)) ||
    (github.event_name == 'pull_request' && github.event.action == 'opened' &&
     contains(fromJSON('["patch", "minor", "major"]'), join(github.event.pull_request.labels.*.name, ',')))
  )

Ref: GitHub Actions — pull_request event payload

Prompt for agents
In `.github/workflows/auto-merge-speakeasy-pr.yaml` line 8, the `opened` trigger was added but the job's `if:` condition at line 21 ends with `contains(fromJSON('["patch", "minor", "major"]'), github.event.label.name)`. On the `opened` event, `github.event.label` is absent, so `github.event.label.name` is an empty string and `contains` returns false — the `auto-merge` job never runs on `opened` events. Either (a) remove `opened` from `types` if the `labeled` event already fires reliably for Speakeasy PRs, or (b) restructure the `if:` condition to check `github.event.pull_request.labels.*.name` (the full label list) when the event action is `opened`, and `github.event.label.name` (the just-applied label) only when the action is `labeled`.

Reviewed at c34ce15


permissions:
contents: write
Expand All @@ -22,7 +22,13 @@ jobs:
github.event.pull_request.user.login == 'github-actions[bot]' &&
startsWith(github.event.pull_request.head.ref, 'speakeasy-sdk-regen-') &&
contains(github.event.pull_request.title, '🐝 Update SDK') &&
contains(fromJSON('["patch", "minor", "major"]'), github.event.label.name)
(
(github.event.action == 'labeled' && contains(fromJSON('["patch", "minor", "major"]'), github.event.label.name)) ||
(github.event.action == 'opened' &&
(contains(github.event.pull_request.labels.*.name, 'patch') ||
contains(github.event.pull_request.labels.*.name, 'minor') ||
contains(github.event.pull_request.labels.*.name, 'major')))
)
runs-on: ubuntu-latest
steps:
- name: Close superseded Speakeasy PRs
Expand Down