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

Action creates two status checks - one passes, one fails. #524

Open
GabeMillikan opened this issue Oct 13, 2023 · 3 comments
Open

Action creates two status checks - one passes, one fails. #524

GabeMillikan opened this issue Oct 13, 2023 · 3 comments

Comments

@GabeMillikan
Copy link

GabeMillikan commented Oct 13, 2023

I have installed the action in accordance with the README.md, such that I have 3 labels:
label a requires 0 reviews
label b requires 1 reviews
label c requires 2 reviews

Steps to reproduce the unexpected behavior:

  1. I open a PR with some changes
  2. I add the b label (such that 1 review is required)
  3. the check (titled pull_request) fails (expectedly, since there are no reviews) and I cannot merge
  4. Someone else approves my PR
  5. A new check (titled pull_request_review) succeeds (due to the approval) but the previous pull_request check is still present and failed and I still cannot merge

image

Is it possible to fix this (without manually re-running the checks)?

Click to see my (very standard) configuration

.github/workflows/label-reviews.yml

# This workflow will set a number or reviewers depending on the labels
name: Label Reviews
# Trigger the workflow on pull requests
on:
  pull_request:
    types:
      - opened
      - reopened
      - synchronize
      - labeled
      - unlabeled
  pull_request_review:
    types:
      - submitted
      - edited
      - dismissed
jobs:
  require-reviewers:
    # Optional: skip check if no relevant label is present
    # This needs to be kept in sync with the labels being checked
    runs-on: ubuntu-latest
    steps:
      - name: Require-reviewers
        uses: travelperk/label-requires-reviews-action@1.3.0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          rules_yaml: | # define which PR labels require how many aprroving reviewers
            a: 0
            b: 1
            c: 2

repository settings

image

@namelivia
Copy link
Collaborator

Hello, this is how I set this up:

on:
  pull_request_review:

and not

on:
  pull_request:

Pull requests already require 1 approval because of the branch protection rule, so the action will run when this first approval comes.
If the tag requires more than 1 approval it will fail and wait for more approvals to come, if no it won't block the pr, but the action is set to run only when approvals come.

I hope this can help you!

@GabeMillikan
Copy link
Author

Thank you! Is it possible to make the check re-run automatically if the tag changes?

@namelivia
Copy link
Collaborator

Thank you! Is it possible to make the check re-run automatically if the tag changes?

This could work:

on:
  pull_request_target:
    types:
      - labeled

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