-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathcreate-commit-rust-cargo-lock.sh
executable file
·38 lines (28 loc) · 1.16 KB
/
create-commit-rust-cargo-lock.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
32
33
34
35
36
37
38
. ./.gh-api-examples.conf
# https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents
# PUT /repos/:owner/:repo/contents/:path
# https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html#cargotoml-vs-cargolock
if [ -z "$1" ]
then
repo=$repo
else
repo=$1
fi
shopt -s -o nounset
source_file="test-data/rust/cargo/Cargo.lock_"
base64_source_file=$(./base64encode.py ${source_file})
content=${base64_source_file}
filename_in_repo="Cargo.lock"
comment="Adding ${filename_in_repo}"
json_file=tmp/create-commit-rust-cargo-lock.json
jq -n \
--arg nm "${default_committer}" \
--arg ms "Adding a ${filename_in_repo} file for ${comment}" \
--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 "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/repos/${org}/${repo}/contents/${filename_in_repo} --data @${json_file}