Last active
December 10, 2024 09:36
-
-
Save dewomser/894edbdba76cb31e5d9924290c35c247 to your computer and use it in GitHub Desktop.
Ein Gist updaten. Das Bashskript benutzt curl, Token . Quelle: Copilot + ich
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 | |
# 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