Skip to content

Commit

Permalink
use python to build request
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartin-tech committed Aug 6, 2024
1 parent fe41f57 commit e3889cc
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/maintain_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,22 @@ jobs:
set -e
echo "Plugin cache updates exist"
if [ ${{ endsWith(github.ref_name, '/main')}} ]; then
export MESSAGE="automatic $FILE_TO_COMMIT update"
export SHA=$( git rev-parse $DESTINATION_BRANCH:$FILE_TO_COMMIT )
cat <<- EOF > request.json
{
"message": "$MESSAGE",
"content": "$( base64 -w 0 -i $FILE_TO_COMMIT )",
cat <<- EOF > write_request.py
#!python
import json
import os
request = {
"message": "automatic $FILE_TO_COMMIT update",
"content": os.environ["CONTENT"],
"encoding": "base64",
"branch":" $DESTINATION_BRANCH",
"sha"= "$SHA"
"branch": "$DESTINATION_BRANCH",
"sha"= "$( git rev-parse $DESTINATION_BRANCH:$FILE_TO_COMMIT )",
}
with open("request.json", "w", encoding="utf-8") as f:
json.dump(request, f, indent=4)
EOF
chmod +x write_request.py
python write_request.py
cat request.json
gh api --method PUT /repos/:owner/:repo/contents/$FILE_TO_COMMIT --input request.json
echo "Update committed to repo"
Expand Down

0 comments on commit e3889cc

Please sign in to comment.