-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathcreate-repo.sh
More file actions
executable file
·40 lines (32 loc) · 1.04 KB
/
Copy pathcreate-repo.sh
File metadata and controls
executable file
·40 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
. ./.gh-api-examples.conf
# https://docs.github.com/en/enterprise-cloud@latest/rest/repos/repos?apiVersion=2022-11-28#create-an-organization-repository
# POST /orgs/{org}/repos
# If the script is passed an argument $1 use that as the name
if [ -z "$1" ]
then
repo=$repo
else
repo=$1
fi
if [ ${default_repo_visibility} = "private" ]
then
p="true"
else
p="false"
fi
json_file=tmp/repo-details.json
jq -n \
--arg name "${repo}" \
--arg private $p \
--arg visibility ${default_repo_visibility} \
--arg delete_branch_on_merge ${delete_branch_on_merge} \
'{
name : $name,
private: $private | test("true"),
visibility: $visibility,
delete_branch_on_merge: $delete_branch_on_merge | test("true")
}' > ${json_file}
curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/orgs/${org}/repos" --data @${json_file}