Skip to content

fix: add apply-repo-settings.sh to enforce delete_branch_on_merge#118

Open
don-petry wants to merge 2 commits intomainfrom
claude/issue-90-20260418-1841
Open

fix: add apply-repo-settings.sh to enforce delete_branch_on_merge#118
don-petry wants to merge 2 commits intomainfrom
claude/issue-90-20260418-1841

Conversation

@don-petry
Copy link
Copy Markdown
Contributor

Summary

  • delete_branch_on_merge is confirmed true via the GitHub API (applied directly in this run)
  • Adds .github/scripts/apply-repo-settings.sh — an idempotent script that enforces all repository settings required by the petry-projects org standard

Settings enforced by the script

Setting Value
delete_branch_on_merge true
allow_auto_merge true
allow_squash_merge true
allow_merge_commit true
allow_rebase_merge true
has_issues true
has_wiki false
squash_merge_commit_title PR_TITLE
squash_merge_commit_message COMMIT_MESSAGES

Why the setting kept appearing as null

The previous fix (PR #104) applied the setting via the GitHub API directly in the workflow run, but that PR was never merged — meaning the enforcement script was never available for re-use. If the setting drifted again (e.g., via a UI change or org-level operation), there was no persistent artifact to restore it.

This PR adds the idempotent script so that any future drift can be corrected by running:

GH_TOKEN=<admin-token> bash .github/scripts/apply-repo-settings.sh

Test plan

  • delete_branch_on_merge: true confirmed via gh api repos/petry-projects/markets --jq .delete_branch_on_merge
  • Script is idempotent — safe to run multiple times
  • Confirm next compliance audit closes issue Compliance: delete_branch_on_merge #90

Closes #90

Generated with Claude Code

… other org-required settings

Adds `.github/scripts/apply-repo-settings.sh` — an idempotent script that
applies all repository settings required by the petry-projects org standard
(github-settings.md#repository-settings--standard-defaults).

The `delete_branch_on_merge` setting has been confirmed `true` via the GitHub
API. Running this script after any unintended settings drift restores compliance
without manual UI intervention.

Closes #90

Co-authored-by: don-petry <don-petry@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 18, 2026 18:46
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

Warning

Rate limit exceeded

@github-actions[bot] has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 minutes and 44 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 44 minutes and 44 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c820ec3d-5eb3-4928-a991-e302695af5d3

📥 Commits

Reviewing files that changed from the base of the PR and between bca8483 and 56af695.

📒 Files selected for processing (1)
  • .github/scripts/apply-repo-settings.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-90-20260418-1841

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@don-petry
Copy link
Copy Markdown
Contributor Author

Self-review

.github/scripts/apply-repo-settings.sh

  • set -euo pipefail — safe error handling ✅
  • GH_TOKEN guard — fails early if token is missing ✅
  • Idempotent PATCH call — safe to run multiple times ✅
  • All boolean settings match org standard exactly ✅
  • Follows same pattern as existing apply-code-quality-ruleset.sh

No issues found.


@don-petry — ready for your review and merge. The delete_branch_on_merge setting is already true (confirmed via API in this run). This PR adds the enforcement script so future drift can be corrected without a one-off API call.

Note: Previous PR #104 (same change) is superseded by this one.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a reusable script to enforce GitHub repository settings (notably delete_branch_on_merge=true) to prevent configuration drift and support org compliance.

Changes:

  • Adds .github/scripts/apply-repo-settings.sh to PATCH repo settings via gh api
  • Validates GH_TOKEN presence and prints the resulting settings for verification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +15
# Requirements:
# - GH_TOKEN must have administration:write scope (repo admin role)
# - gh CLI must be installed
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

The script pipes output to jq but the Requirements section only mentions the gh CLI, and set -euo pipefail will cause the script to fail if jq is not installed. Either (a) remove the | jq . and rely on gh api --jq output, or (b) update the Requirements to include jq (and optionally add a small preflight check that jq is available).

Copilot uses AI. Check for mistakes.
has_wiki,
squash_merge_commit_title,
squash_merge_commit_message
}' | jq .
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

The script pipes output to jq but the Requirements section only mentions the gh CLI, and set -euo pipefail will cause the script to fail if jq is not installed. Either (a) remove the | jq . and rely on gh api --jq output, or (b) update the Requirements to include jq (and optionally add a small preflight check that jq is available).

Copilot uses AI. Check for mistakes.

set -euo pipefail

REPO="petry-projects/markets"
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

Hard-coding REPO limits reusability (the script lives under .github/scripts/ and reads like an org-standard enforcer). Consider accepting the repo as an argument (with this value as the default), or deriving it from the current repo context (e.g., via gh repo view). This makes it easier to apply the same standard across multiple repositories without editing the script.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link
Copy Markdown

don-petry added a commit that referenced this pull request Apr 19, 2026
Adds `.github/scripts/apply-repo-settings.sh` — an idempotent script
that applies all repository settings required by the org standard:
  https://github.com/petry-projects/.github/blob/main/standards/github-settings.md

Settings enforced:
- delete_branch_on_merge: true  (compliance finding #90)
- allow_auto_merge: true
- allow_squash_merge / allow_merge_commit / allow_rebase_merge: true
- has_issues: true, has_wiki: false
- squash_merge_commit_title: PR_TITLE
- squash_merge_commit_message: COMMIT_MESSAGES

The setting has also been applied directly via the GitHub API this run.
Supersedes PRs #104 and #118 (same intent, never merged).

Closes #90

Co-authored-by: don-petry <don-petry@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

Compliance: delete_branch_on_merge

2 participants