Skip to content

Instantly share code, notes, and snippets.

@defrindr
Forked from aborruso/updatefile.sh
Created April 29, 2020 12:14
Show Gist options
  • Save defrindr/7368285b82fc6743dd6e154b4c5d4756 to your computer and use it in GitHub Desktop.
Save defrindr/7368285b82fc6743dd6e154b4c5d4756 to your computer and use it in GitHub Desktop.
How to update a file in github via cURL
#!/bin/bash
cartella="/var/myfolder"
# update the file
curl -i -X PUT -H 'Authorization: token 4d013330xxxxxxxxxxxxxx' -d "{\"path\": \"mattei.csv\", \
\"message\": \"update\", \"content\": \"$(openssl base64 -A -in $cartella/mattei.csv)\", \"branch\": \"master\",\
\"sha\": $(curl -X GET https://api.github.com/repos/username/repo/contents/mattei.csv | jq .sha)}" \
https://api.github.com/repos/username/repo/contents/mattei.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment