Skip to content

Commit b3e191a

Browse files
committed
fix: run project structure check on every PR
1 parent 12c0a21 commit b3e191a

3 files changed

Lines changed: 38 additions & 6 deletions

File tree

.github/workflows/project-structure.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Project structure
22

33
on:
44
pull_request:
5-
paths:
6-
- 'projects/**'
5+
push:
6+
branches: [main]
77

88
permissions:
99
contents: read

scripts/github/configure-repository.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
set -euo pipefail
33

44
dry_run=false
5-
[[ "${1:-}" == "--dry-run" ]] && dry_run=true
5+
apply_protection=false
6+
for argument in "$@"; do
7+
[[ "$argument" == "--dry-run" ]] && dry_run=true
8+
[[ "$argument" == "--apply-branch-protection" ]] && apply_protection=true
9+
done
610
command -v gh >/dev/null || { echo 'GitHub CLI is required.'; exit 1; }
711
gh auth status
812
org="${GITHUB_ORG:?Set GITHUB_ORG}"
913
repo="${GITHUB_REPO:-ai-community}"
10-
echo "Proposed settings for $org/$repo: public repository, description/topics, Discussions enabled, and main branch rules: PRs, one approval, resolved conversations, required checks, no force pushes."
11-
echo 'Review current GitHub plan and existing rules before applying. This script intentionally does not change branch protection or existing security settings.'
14+
visibility="$(gh repo view "$org/$repo" --json visibility --jq .visibility)"
15+
[[ "$visibility" == "PUBLIC" ]] || { echo 'Branch protection requires a public repository on this organization plan.'; exit 1; }
16+
echo "Proposed protection for $org/$repo main: PRs, one approval, resolved conversations, required checks, no force pushes, and administrator enforcement."
1217
$dry_run && exit 0
13-
echo 'No changes made: branch protection requires an explicit reviewed configuration for the detected GitHub plan.'
18+
$apply_protection || { echo 'No changes made. Use --apply-branch-protection after reviewing scripts/github/main-branch-protection.json.'; exit 0; }
19+
gh api --method PUT "repos/$org/$repo/branches/main/protection" --input scripts/github/main-branch-protection.json >/dev/null
20+
echo 'Applied main branch protection.'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"required_status_checks": {
3+
"strict": true,
4+
"contexts": [
5+
"Validate pull request / validate",
6+
"Markdown check / markdown",
7+
"Project structure / project-readme"
8+
]
9+
},
10+
"enforce_admins": true,
11+
"required_pull_request_reviews": {
12+
"dismiss_stale_reviews": true,
13+
"require_code_owner_reviews": false,
14+
"required_approving_review_count": 1,
15+
"require_last_push_approval": false
16+
},
17+
"restrictions": null,
18+
"required_linear_history": false,
19+
"allow_force_pushes": false,
20+
"allow_deletions": false,
21+
"block_creations": false,
22+
"required_conversation_resolution": true,
23+
"lock_branch": false,
24+
"allow_fork_syncing": true
25+
}

0 commit comments

Comments
 (0)