forked from gm3dmo/the-power
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-commit-codeowners.sh
executable file
·31 lines (25 loc) · 1018 Bytes
/
create-commit-codeowners.sh
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
. .gh-api-examples.conf
# https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents
# PUT /repos/:owner/:repo/contents/:path
if [ -z "$1" ]
then
repo=$repo
else
repo=$1
fi
raw_text="/docs/README.md @${org}/${team_slug}\n/.gitattributes @${default_committer}"
base64_string=$(echo ${raw_text} | base64)
content=${base64_string}
filename_in_repo=CODEOWNERS
json_file=tmp/create-commit-codeowners.json
jq -n \
--arg nm "${default_committer}" \
--arg ms "Create a CODEOWNERS file" \
--arg em "${USER}+${default_committer}@${mail_domain}" \
--arg ct "${content}" \
'{message: $ms, "committer":{ "name" : $nm, "email": $em }, content: $ct }' > ${json_file}
curl ${curl_custom_flags} \
-X PUT \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
${GITHUB_API_BASE_URL}/repos/${org}/${repo}/contents/${filename_in_repo} --data @${json_file}