I'm trying to clone a remote repo, open a certain yaml file, update a couple keys, then stage and push it back to remote. But I can't stage nor commit the file, since my script seems to be ignoring my updates.
I load the file and add the keys I want to update into a update_values variable
yaml_file_path = "build.yml"
try:
with open(yaml_file_path, 'r') as file:
data = yaml.safe_load(file)
update_values = {
'key1': 'q700mb',
'key2': 'xyz',
}
then try to "write" the updates back into it
for key, value in update_values.items():
if key in data:
data[key] = value
with open(yaml_file_path, 'w') as file:
yaml.dump(data, file)
except Exception as e:
print("error when touching the YAML file: {e}")
My commit fails stating there is nothing to be updated. Then I open and log the content of the file I expect to be update, just to check
print("updated yaml file: ")
with open(yaml_file_path,'r') as file:
updated_yaml = file.read()
print(updated_yaml)
But everything remains untouched