Skip to content

Instantly share code, notes, and snippets.

@adi928
Created April 10, 2021 21:39
Show Gist options
  • Save adi928/ed7157912ef871c49dd9b273476c811a to your computer and use it in GitHub Desktop.
Save adi928/ed7157912ef871c49dd9b273476c811a to your computer and use it in GitHub Desktop.
Part of a blog elaborating the confluence to azure app service workflow
import json
commitMsg = "Testing 101"
changesList = []
for f_name in filesInZip:
if f_name.split('.')[-1] in ['html', 'css', 'js', 'aspx', 'scss']:
print("[+] Adding file: "+f_name)
else:
print("[+] Skipping file: "+ f_name)
continue
with open("/tmp/"+filename.split('.')[0]+"/"+f_name, "r") as fileContent:
f_content = fileContent.read()
newContentObj = {}
newContentObj["content"] = f_content.replace('"','\"')
newContentObj["contentType"] = "rawtext"
changesObj = {}
changesObj["item"] = json.loads('{"path": "/'+f_name+'"}')
changesObj["newContent"] = newContentObj
if fileExists(f_name) == 200:
changesObj["changeType"] = "edit"
else:
changesObj["changeType"] = "add"
changesList.append(changesObj) # CHange this to .append
refUpdates = {}
# Update both these lines if we variablize the branch name
refUpdates["name"] = "refs/heads/master"
refUpdates["oldObjectId"] = getRefObjectId("master")
commitObj = {}
commitObj["comment"] = commitMsg
commitObj["changes"] = changesList
postObj = {}
postObj["refUpdates"] = [refUpdates]
postObj["commits"] = [commitObj]
with open("/tmp/payloadBody.json","w") as pb:
json.dump(postObj, pb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment