Repository navigation
fix: add apply-repo-settings.sh to enforce delete_branch_on_merge #127
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
Closed
Closed
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
81f7514
fix: add apply-repo-settings.sh to enforce delete_branch_on_merge
github-actions[bot] 7b75612
fix: add has_discussions=true to apply-repo-settings.sh
github-actions[bot] 32125be
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 3c66e2a
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 585d879
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] cec163d
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 42196a6
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 0577152
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 64b0a3d
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 5e657df
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 7602a8c
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 6576104
fix: address Copilot review comments on apply-repo-settings.sh
github-actions[bot] 1c414b1
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] d7f327f
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 4c4431e
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 0b918fe
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 6f6d391
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 0455d88
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 048c655
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 60ad2d4
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 685b9c7
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] fa14afa
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] b595d78
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] e42b6d6
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 86376d6
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 4e91e67
Merge branch 'main' into claude/issue-90-20260419-1733
github-actions[bot] 73058b1
Merge branch 'main' into claude/issue-90-20260419-1733
don-petry 65e1e6f
Merge branch 'main' into claude/issue-90-20260419-1733
don-petry 88ddc7c
Merge branch 'main' into claude/issue-90-20260419-1733
don-petry 1b0e329
Merge branch 'main' into claude/issue-90-20260419-1733
don-petry 354686c
Merge branch 'main' into claude/issue-90-20260419-1733
don-petry edce2a1
Merge branch 'main' into claude/issue-90-20260419-1733
don-petry 624f854
Merge branch 'main' into claude/issue-90-20260419-1733
don-petry 07c60fe
Merge branch 'main' into claude/issue-90-20260419-1733
don-petry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| #!/usr/bin/env bash | ||
| # apply-repo-settings.sh — Idempotently apply required repository settings | ||
| # | ||
| # Enforces all settings required by the petry-projects org standard: | ||
| # https://github.com/petry-projects/.github/blob/main/standards/github-settings.md#repository-settings--standard-defaults | ||
| # | ||
| # Usage: | ||
| # GH_TOKEN=<admin-token> bash .github/scripts/apply-repo-settings.sh | ||
| # | ||
| # The script is safe to run multiple times (idempotent). It fetches and prints | ||
| # the current relevant settings, applies the required settings using the | ||
| # GitHub REST API, and prints the resulting settings response. | ||
| # | ||
| # Requirements: | ||
| # - GH_TOKEN must have administration:write scope (repo admin role) | ||
| # - gh CLI must be installed | ||
| # - jq must be installed | ||
| # | ||
| # The org-level script (petry-projects/.github/scripts/apply-repo-settings.sh) | ||
| # is the canonical tool for managing settings across all repos. This script | ||
| # exists as a repo-local reference and fallback for the markets repository. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| REPO="petry-projects/markets" | ||
|
|
||
| if [ -z "${GH_TOKEN:-}" ]; then | ||
| echo "ERROR: GH_TOKEN is required with administration:write scope" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! command -v jq &>/dev/null; then | ||
| echo "ERROR: jq is required but not found in PATH" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| export GH_TOKEN | ||
|
|
||
| echo "Fetching current settings for $REPO ..." | ||
| current=$(gh api "repos/$REPO" --jq '{ | ||
| allow_auto_merge: .allow_auto_merge, | ||
| delete_branch_on_merge: .delete_branch_on_merge, | ||
| allow_squash_merge: .allow_squash_merge, | ||
| allow_merge_commit: .allow_merge_commit, | ||
| allow_rebase_merge: .allow_rebase_merge, | ||
| has_discussions: .has_discussions, | ||
| has_issues: .has_issues, | ||
| has_wiki: .has_wiki, | ||
| squash_merge_commit_title: .squash_merge_commit_title, | ||
| squash_merge_commit_message: .squash_merge_commit_message | ||
| }') | ||
|
|
||
| echo "Current settings:" | ||
| echo "$current" | jq . | ||
|
|
||
| echo "" | ||
| echo "Applying required settings to $REPO ..." | ||
| gh api -X PATCH "repos/$REPO" \ | ||
| -F delete_branch_on_merge=true \ | ||
| -F allow_auto_merge=true \ | ||
| -F allow_squash_merge=true \ | ||
| -F allow_merge_commit=true \ | ||
| -F allow_rebase_merge=true \ | ||
| -F has_discussions=true \ | ||
| -F has_issues=true \ | ||
| -F has_wiki=false \ | ||
| -f squash_merge_commit_title=PR_TITLE \ | ||
| -f squash_merge_commit_message=COMMIT_MESSAGES \ | ||
| --jq '{ | ||
| delete_branch_on_merge, | ||
| allow_auto_merge, | ||
| allow_squash_merge, | ||
| allow_merge_commit, | ||
| allow_rebase_merge, | ||
| has_discussions, | ||
| has_issues, | ||
| has_wiki, | ||
| squash_merge_commit_title, | ||
| squash_merge_commit_message | ||
| }' | jq . | ||
|
|
||
| echo "" | ||
| echo "Done — repository settings applied: https://github.com/$REPO/settings" | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script relies on
jqfor pretty-printing output (| jq .), butjqisn’t listed under Requirements. Either addjqto the Requirements section and/or add a clear preflight check (e.g.,command -v jq) so the script fails with a helpful message when jq is missing.