Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with GitHub merge-queue #366

Open
yanns opened this issue Mar 2, 2023 · 4 comments
Open

Integration with GitHub merge-queue #366

yanns opened this issue Mar 2, 2023 · 4 comments

Comments

@yanns
Copy link

yanns commented Mar 2, 2023

When using GitHub merge-queue, GitHub creates new branch for merging pull requests.

This brings two issues.

First, the label checker is running only on pull requests:
The documentation specifies the trigger as follow:

on:
  pull_request:

This can be fixed by adding this trigger:

  merge_group:
    types: [checks_requested]

Second, even if we run the label checker on those branches to be merged, we have an issue as they are no pull requests for them, and no labels. The check fails with the error message:

Checking GitHub labels ...
2023/03/02 10:34:20 Error that we cannot handle, Could not resolve to a PullRequest with the number of 0.

What can we do?
Maybe we can detect if the action is run for a branch for the merge-queue, and always succeed in that case?

@yanns
Copy link
Author

yanns commented Mar 2, 2023

@johnboyes
Copy link
Contributor

Hi @yanns, thanks for raising this. The GitHub merge queue functionality is currently in beta, I see, and the beta was announced less than a month ago. In GitHub's documentation for the feature they say:

The pull request merge queue feature is currently in public beta and subject to change.

That being the case, I'm minded to wait until the feature is more stable before working on a potential solution, if that sounds reasonable? It sounds to me like the issues you have outlined are fairly generic to the new merge queue functionality rather than specific to the label checker, so I'm thinking there is a reasonable chance that GitHub will provide a more generic solution in the coming months 🤞🏻

Let me know what you think, thanks

@yanns
Copy link
Author

yanns commented Mar 2, 2023

👍
I'll add some info to this issue if I find a solution.

@yanns
Copy link
Author

yanns commented Mar 2, 2023

OK I found a way to make it work. I hope this can help others.

name: Label Checker
on:
  pull_request:
    types:
      - opened
      - synchronize
      - reopened
      - labeled
      - unlabeled
  merge_group:
    types: [checks_requested]

jobs:
  check_labels:
    if: github.event_name == 'pull_request'
    name: Check labels
    runs-on: ubuntu-latest
    steps:
      - uses: docker://agilepathway/pull-request-label-checker:latest
        with:
          one_of: major,minor,patch
          repo_token: ${{ secrets.GITHUB_TOKEN }}

Explanations:

  • the action run on merge branches thanks to the on merge_group
  • the action does not do anything on merge branches thanks to the if: github.event_name == 'pull_request'. GitHub accepts this and the PR can be merged.

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

No branches or pull requests

2 participants