Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ indent_size = 2

[*.md]
trim_trailing_whitespace = false

1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ assignees: ""
- Release or rollback urgency:

## Additional Context

1 change: 0 additions & 1 deletion .github/workflows/ci.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ jobs:
- uses: actions/checkout@v4
# Replace with project-specific setup and validation commands.
- run: echo "Configure CI for this project"

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- `configure-github-repository.sh` accepts `--approvals N` (use 0 for a single maintainer) and repeatable `--check NAME` for project CI jobs.
- Removed trailing blank lines that failed `git diff --cached --check` in repositories copying the template files.
- Plans now pair technical decisions with a detailed execution plan: preconditions, completion contract, ordered tasks with exit conditions, validation ledger, and rollback per batch.
- Added `scripts/check-pr-body.sh` and a `PR description` review job that require template sections, real Summary and Validation content, and no agent attribution lines.
- PR title checks now reject CJK characters; bot-generated PRs must use conventional titles too.
Expand Down
1 change: 0 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ Before making changes:
4. Do not commit local config, credentials, generated logs, temporary workspaces, build artifacts, or machine-specific paths.

For substantial changes, follow the Spec/Plan selection rules in `CONTRIBUTING.md`.

4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ Template files do not carry GitHub branch protection settings into every new rep
./scripts/configure-github-repository.sh --repo OWNER/REPO --apply
```

The setup script requires a GitHub account or token with permission to edit repository settings. It protects the default branch by requiring pull requests, one approving review, fresh reviews after new pushes, linear history, resolved conversations, and the `Review` workflow checks named `repository checks`, `conventional PR title`, and `PR description`.
The setup script requires a GitHub account or token with permission to edit repository settings. It protects the default branch by requiring pull requests, one approving review (fresh after new pushes), linear history, resolved conversations, and the `Review` workflow checks named `repository checks`, `conventional PR title`, and `PR description`.

A repository with a single maintainer cannot approve its own pull requests; pass `--approvals 0` to keep the other protections without a review requirement. Add the project's CI job names with `--check NAME` (repeatable) so they are required too. If the repository already uses a ruleset, add these checks to the ruleset instead of layering classic branch protection on top.

## Security Reports

Expand Down
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1 change: 0 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ Please include:
## Sensitive Data

Do not include tokens, private keys, local credentials, internal hostnames, or personal filesystem paths in issues, pull requests, commits, logs, screenshots, or test fixtures.

54 changes: 44 additions & 10 deletions scripts/configure-github-repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ set -euo pipefail
apply=false
repo=""
branch=""
approvals=1
extra_checks=()

usage() {
cat <<'USAGE'
Usage:
scripts/configure-github-repository.sh [--repo OWNER/REPO] [--branch BRANCH] [--apply]
scripts/configure-github-repository.sh [--repo OWNER/REPO] [--branch BRANCH]
[--approvals N] [--check NAME]... [--apply]

Configures GitHub repository defaults that cannot be inherited from template files.

Defaults:
--repo inferred from gh repo view
--branch inferred from the GitHub default branch when gh is available
--branch inferred from the GitHub default branch when gh is available
--approvals 1; use 0 for a repository with a single maintainer, who cannot
approve their own pull requests
--check additional required status check (repeatable), such as the
project's CI job names

Without --apply, this script prints the branch protection payload and does not call GitHub.
USAGE
Expand All @@ -34,6 +41,14 @@ while [[ $# -gt 0 ]]; do
branch="${2:-}"
shift 2
;;
--approvals)
approvals="${2:-}"
shift 2
;;
--check)
extra_checks+=("${2:-}")
shift 2
;;
-h|--help)
usage
exit 0
Expand Down Expand Up @@ -68,22 +83,41 @@ if [[ -z "$branch" ]]; then
fi
fi

payload="$(cat <<'JSON'
if [[ ! "$approvals" =~ ^[0-9]+$ ]]; then
printf 'configure-github-repository: --approvals must be a non-negative integer\n' >&2
exit 1
fi
if (( approvals > 0 )); then
last_push_approval=true
else
last_push_approval=false
fi

contexts=("repository checks" "conventional PR title" "PR description")
if (( ${#extra_checks[@]} > 0 )); then
contexts+=("${extra_checks[@]}")
fi
contexts_json=""
for context in "${contexts[@]}"; do
if [[ -z "$context" || "$context" == *'"'* || "$context" == *\\* ]]; then
printf 'configure-github-repository: invalid check name: %s\n' "$context" >&2
exit 1
fi
contexts_json+="${contexts_json:+, }\"${context}\""
done

payload="$(cat <<JSON
{
"required_status_checks": {
"strict": true,
"contexts": [
"repository checks",
"conventional PR title",
"PR description"
]
"contexts": [${contexts_json}]
},
"enforce_admins": true,
"required_pull_request_reviews": {
"dismiss_stale_reviews": true,
"require_code_owner_reviews": false,
"require_last_push_approval": true,
"required_approving_review_count": 1
"require_last_push_approval": ${last_push_approval},
"required_approving_review_count": ${approvals}
},
"restrictions": null,
"required_linear_history": true,
Expand Down
Loading