From e3889cc4ca2f662a7c8bb143707f81569ddccefa Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Mon, 5 Aug 2024 20:36:35 -0500 Subject: [PATCH] use python to build request --- .github/workflows/maintain_cache.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/maintain_cache.yml b/.github/workflows/maintain_cache.yml index 6160d3080..aa4b8ded9 100644 --- a/.github/workflows/maintain_cache.yml +++ b/.github/workflows/maintain_cache.yml @@ -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"