44
55version=$1
66cd ~ /Documents/gh/github
7+
8+ # Teams are addressed by numeric ID because IDs survive team renames and slugs do not.
9+ # Some APIs (repo creation, CODEOWNERS, custom properties) only accept slugs, so
10+ # resolve the current slug from the ID at runtime rather than hardcoding it.
11+ org_id=9919
12+ docs_team_id=325922
13+ docs_eng_team_id=3935808
14+ docs_team=$( gh api " /organizations/$org_id /team/$docs_team_id " --jq .slug)
15+ docs_eng_team=$( gh api " /organizations/$org_id /team/$docs_eng_team_id " --jq .slug)
16+
717echo " --- Creating repository for github/docs-ghes-$version "
818echo " --- gh repo create"
919gh repo create \
@@ -15,7 +25,7 @@ gh repo create \
1525 --disable-wiki \
1626 --license=" CC-BY-4.0" \
1727 --private \
18- --team=" docs-engineering " \
28+ --team=" $docs_eng_team " \
1929 --homepage=" https://github.github.com/docs-ghes-$version /"
2030echo " --- gh repo edit"
2131gh repo edit \
@@ -27,8 +37,8 @@ gh repo edit \
2737 --enable-projects=false \
2838 --enable-merge-commit=false \
2939 --enable-rebase-merge=false
30- echo " --- github/docs-engineering as admin"
31- gh api -X PUT " /orgs/github/teams/docs-engineering /repos/github/docs-ghes-$version " \
40+ echo " --- github/$docs_eng_team as admin"
41+ gh api -X PUT " /organizations/ $org_id /team/ $docs_eng_team_id /repos/github/docs-ghes-$version " \
3242 -f ' permission=admin' --silent
3343echo " --- github/employees as read"
3444gh api -X PUT " /orgs/github/teams/employees/repos/github/docs-ghes-$version " --silent
@@ -66,15 +76,15 @@ gh api -X POST "/repos/github/docs-ghes-$version/pages" \
6676echo " --- Update custom properties"
6777gh api --method PATCH /repos/github/docs-ghes-$version /properties/values \
6878 -f " properties[][property_name]=ownership-name" \
69- -f " properties[][value]=@github/docs " \
79+ -f " properties[][value]=@github/$docs_team " \
7080 -f " properties[][property_name]=ownership-type" \
7181 -f " properties[][value]=Team" \
7282 --silent
7383echo " --- FILE UPDATES"
7484cd " docs-ghes-$version "
7585echo " --- docs engineering as codeowners"
7686touch CODEOWNERS
77- echo " * @github/docs-engineering " > CODEOWNERS
87+ echo " * @github/$docs_eng_team " > CODEOWNERS
7888echo " --- add index.html file"
7989touch index.html
8090echo " <h1>GitHub Enterprise Server $version Docs</h1>" > index.html
0 commit comments