Last active
October 24, 2023 19:41
-
-
Save shalomb/61e19a41f23a34bb69022ff8945f14f3 to your computer and use it in GitHub Desktop.
Update git content via API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu -o pipefail | |
content="foo and bar and baz" | |
content="$(base64 <<<"$content")" | |
sha=$(git ls-files -s foo | awk '{print $2}') | |
# curl -L \ | |
# -X DELETE \ | |
# -H "Accept: application/vnd.github+json" \ | |
# -H "Authorization: Bearer ghp_4YXXXXXXJN" \ | |
# -H "X-GitHub-Api-Version: 2022-11-28" \ | |
# https://api.github.com/repos/octokat/terraform-developer-ShalomBhooshi/contents/foo \ | |
# -d '{"message":"my commit message","committer":{"name":"Monalisa Octocat","email":"[email protected]"},"sha":"0d5a690c8fad5e605a6e8766295d9d459d65de42"}' | |
curl -L \ | |
-X PUT \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ghp_4YXXXXXXJN" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/oktokat/demorepo/contents/foo \ | |
-d '{ | |
"message":"my commit message", | |
"branch": "bom-stream", | |
"committer":{ | |
"name":"Monalisa Octocat", | |
"email":"[email protected]" | |
}, | |
"content":"'"$content"'", | |
"sha": "'"$sha"'" | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment