Step 1: Create a personal access token on GitHub.
Step 2: Create a new commit in the GitHub repository using REST API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
## Declare some Variables GITHUB_PAT_TOKEN=' GITHUB_REPO_NAME=' GITHUB_USER_NAME=' ## Convert the content of the file in base64 echo 'hello world' | base64 # returns aGVsbG8gd29ybGQK ## Create a new file or directory in GitHub remote repository curl \ --request PUT \ --silent \ --header "Authorization: token $GITHUB_PAT_TOKEN" \ --data '{"message":"file myfile1.txt added","content":"aGVsbG8gd29ybGQK"}' \ https://api.github.com/repos/$GITHUB_USER_NAME/$GITHUB_REPO_NAME/contents/mydir1/myfile1.txt |