Last active
November 28, 2024 20:44
-
-
Save RammusXu/f3a01b4fe0fbc2096d65bf36204580ed to your computer and use it in GitHub Desktop.
Github REST API update file with commit
This file contains hidden or 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
REPO=rammus/action-demo | |
FILE=README.md | |
INPUT_GITHUB_TOKEN= | |
# https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-content | |
curl \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Authorization: token $INPUT_GITHUB_TOKEN" \ | |
"https://api.github.com/repos/${REPO}/contents/${FILE}" | |
# https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#create-or-update-file-contents | |
curl \ | |
-X PUT \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Authorization: token $INPUT_GITHUB_TOKEN" \ | |
"https://api.github.com/repos/${REPO}/contents/${FILE}" \ | |
-d '{"message":"message","content":"'$(echo content|base64)'", "sha":"SHA_FROM_ABOVE"}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment