Skip to content

Instantly share code, notes, and snippets.

@dewomser
Last active December 10, 2024 09:36
Show Gist options
  • Save dewomser/894edbdba76cb31e5d9924290c35c247 to your computer and use it in GitHub Desktop.
Save dewomser/894edbdba76cb31e5d9924290c35c247 to your computer and use it in GitHub Desktop.
Ein Gist updaten. Das Bashskript benutzt curl, Token . Quelle: Copilot + ich
!/bin/bash
# Setze die Variablen
GIST_ID="99ad8c8128785c1c0b35e16a42f8b08c"
FILE_NAME="test.md"
GITHUB_TOKEN="dein_github_token"
GIST_URL="https://api.github.com/gists/$GIST_ID"
# Lese den Inhalt der Datei
CONTENT=$(cat $FILE_NAME)
# Erstelle das JSON-Daten-Objekt
JSON_DATA=$(jq -n --arg content "$CONTENT" --arg filename "$FILE_NAME" '{
"files": {
($filename): {
"content": $content
}
}
}')
# Sende die Anfrage an die GitHub API
curl -X PATCH "$GIST_URL" \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d "$JSON_DATA"
echo "Gist $GIST_ID wurde aktualisiert."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment