Repository navigation
Conversation
Adds a GitHub Actions check that fails when the `do-not-merge` label is present on a PR. Requires adding this as a required status check in branch protection rules to actually prevent merging. Note: partially generated by AI Signed-off-by: Saif Chaudhry <schaudhr@redhat.com>
|
Skipping CI for Draft Pull Request. |
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The LABELS check relies on
grepagainst the JSON-encoded label list, which is a bit brittle; consider using a workflow-level conditional likeif: contains(join(github.event.pull_request.labels.*.name, ','), 'do-not-merge')or parsing viajqfor a more robust and readable check. - If you expect labels with different casing or variants (e.g.
Do Not Merge), you may want to either normalize label names to lowercase before checking or support a small set of allowed label strings to avoid false negatives.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The LABELS check relies on `grep` against the JSON-encoded label list, which is a bit brittle; consider using a workflow-level conditional like `if: contains(join(github.event.pull_request.labels.*.name, ','), 'do-not-merge')` or parsing via `jq` for a more robust and readable check.
- If you expect labels with different casing or variants (e.g. `Do Not Merge`), you may want to either normalize label names to lowercase before checking or support a small set of allowed label strings to avoid false negatives.
## Individual Comments
### Comment 1
<location path=".github/workflows/do-not-merge.yaml" line_range="11-15" />
<code_context>
+ do-not-merge:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Block merge if do-not-merge label is present
+ env:
+ LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
+ run: |
+ if echo "$LABELS" | grep -q 'do-not-merge'; then
+ echo "::error::PR has the 'do-not-merge' label. Remove it before merging."
+ exit 1
</code_context>
<issue_to_address>
**suggestion:** Consider using a native GitHub Actions `if:` condition instead of a shell `grep` to check for the label.
You can express this entirely in the workflow using GitHub’s expression syntax, avoiding the extra shell step and JSON handling:
```yaml
jobs:
do-not-merge:
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'do-not-merge') }}
steps:
- run: |
echo "::error::PR has the 'do-not-merge' label. Remove it before merging."
exit 1
```
This keeps the check declarative and makes the condition visible in the workflow UI instead of buried in a script.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
|
Images are ready for the commit at e5280af. To use with deploy scripts, first |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19292 +/- ##
=======================================
Coverage 49.61% 49.62%
=======================================
Files 2680 2680
Lines 202195 202214 +19
=======================================
+ Hits 100316 100339 +23
+ Misses 94399 94397 -2
+ Partials 7480 7478 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a GitHub Actions workflow that fails when the
do-not-mergelabel is present on a PR. This prevents accidental merges of PRs that are explicitly marked as not ready.To fully enforce this,
Do Not Mergemust be added as a required status check in branch protection rules formaster.Settings > Branches > Branch protection rules for master
User-facing documentation
Testing and quality
Automated testing
How I validated my change