travelperk / label-requires-reviews-action

This Github action will require a minimum number of reviews if a label is present
MIT License
14 stars 8 forks source link

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

Open GabeMillikan opened 1 year ago

GabeMillikan commented 1 year ago

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` ```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](https://github.com/travelperk/label-requires-reviews-action/assets/44247924/94e36ba4-97b6-480d-991b-55f9c0dbf89a)
namelivia commented 12 months ago

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 commented 12 months ago

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

namelivia commented 12 months ago

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