From 81f7514397a2772d0582cfc86b8b29791db97734 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:39:30 +0000 Subject: [PATCH 1/3] fix: add apply-repo-settings.sh to enforce delete_branch_on_merge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .github/scripts/apply-repo-settings.sh | 73 ++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/scripts/apply-repo-settings.sh diff --git a/.github/scripts/apply-repo-settings.sh b/.github/scripts/apply-repo-settings.sh new file mode 100644 index 00000000..a20f5a5a --- /dev/null +++ b/.github/scripts/apply-repo-settings.sh @@ -0,0 +1,73 @@ +#!/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= bash .github/scripts/apply-repo-settings.sh +# +# The script is safe to run multiple times (idempotent). It applies settings +# using the GitHub REST API and prints each current vs. expected value. +# +# Requirements: +# - GH_TOKEN must have administration:write scope (repo admin role) +# - gh CLI 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 + +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_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_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_issues, + has_wiki, + squash_merge_commit_title, + squash_merge_commit_message + }' | jq . + +echo "" +echo "Done — repository settings applied: https://github.com/$REPO/settings" From 7b7561234692850adf3b398746dd6059f18bfa30 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 17:40:44 +0000 Subject: [PATCH 2/3] fix: add has_discussions=true to apply-repo-settings.sh Adds `has_discussions` to the settings enforced by the script, matching the full set checked by the org compliance audit (has_discussions is an error-level check alongside delete_branch_on_merge). Co-authored-by: don-petry --- .github/scripts/apply-repo-settings.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/scripts/apply-repo-settings.sh b/.github/scripts/apply-repo-settings.sh index a20f5a5a..6971326d 100644 --- a/.github/scripts/apply-repo-settings.sh +++ b/.github/scripts/apply-repo-settings.sh @@ -36,6 +36,7 @@ current=$(gh api "repos/$REPO" --jq '{ 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, @@ -53,6 +54,7 @@ gh api -X PATCH "repos/$REPO" \ -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 \ @@ -63,6 +65,7 @@ gh api -X PATCH "repos/$REPO" \ allow_squash_merge, allow_merge_commit, allow_rebase_merge, + has_discussions, has_issues, has_wiki, squash_merge_commit_title, From 657610462459ba2838db5909e70557dd429a33dd Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Wed, 6 May 2026 11:37:32 +0000 Subject: [PATCH 3/3] fix: address Copilot review comments on apply-repo-settings.sh - Fix header comment to accurately describe script behavior (fetches current settings, applies via API, prints resulting response) - Add jq to Requirements section in script header - Add preflight check for jq with clear error message on missing dependency Co-authored-by: Don Petry --- .github/scripts/apply-repo-settings.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/scripts/apply-repo-settings.sh b/.github/scripts/apply-repo-settings.sh index 6971326d..6411911c 100644 --- a/.github/scripts/apply-repo-settings.sh +++ b/.github/scripts/apply-repo-settings.sh @@ -7,12 +7,14 @@ # Usage: # GH_TOKEN= bash .github/scripts/apply-repo-settings.sh # -# The script is safe to run multiple times (idempotent). It applies settings -# using the GitHub REST API and prints each current vs. expected value. +# 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 @@ -27,6 +29,11 @@ if [ -z "${GH_TOKEN:-}" ]; then 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 ..."