Skip to content

ci: add do-not-merge label check workflow - #19292

Closed
sachaudh wants to merge 1 commit into
masterfrom
ci/do-not-merge-check
Closed

sachaudh wants to merge 1 commit into
masterfrom
ci/do-not-merge-check

Conversation

@sachaudh

@sachaudh sachaudh commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds a GitHub Actions workflow that fails when the do-not-merge label is present on a PR. This prevents accidental merges of PRs that are explicitly marked as not ready.

To fully enforce this, Do Not Merge must be added as a required status check in branch protection rules for master.

Settings > Branches > Branch protection rules for master

User-facing documentation

Testing and quality

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  • Reviewed the workflow YAML for correctness
  • CI workflow is simple enough that manual validation is sufficient

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>
@openshift-ci

openshift-ci Bot commented Mar 4, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@sachaudh sachaudh added the do-not-merge A change which is not meant to be merged label Mar 4, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/do-not-merge.yaml
@sachaudh sachaudh removed do-not-merge A change which is not meant to be merged do-not-merge/work-in-progress labels Mar 4, 2026
@sachaudh sachaudh closed this Mar 4, 2026
@rhacs-bot

Copy link
Copy Markdown
Contributor

Images are ready for the commit at e5280af.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x-230-ge5280afad9.

@codecov

codecov Bot commented Mar 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.62%. Comparing base (fe658b3) to head (e5280af).
⚠️ Report is 11 commits behind head on master.

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     
Flag Coverage Δ
go-unit-tests 49.62% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants