I have a script that runs in Gitlab CI that checkouts a new branch and runs 'npm run docs'. This updates various markdown files based on the changes since the last run. If there are any changes, the script will commit the changes and create a new MR. The Gitlab docs show an example of multi file commits but it seems like you have to know which files will change.
PAYLOAD=$(cat << 'JSON'
{
"branch": "master",
"commit_message": "some commit message",
"actions": [
{
"action": "create",
"file_path": "foo/bar",
"content": "some content"
},
{
"action": "delete",
"file_path": "foo/bar2"
},
{
"action": "move",
"file_path": "foo/bar3",
"previous_path": "foo/bar4",
"content": "some content"
},
{
"action": "update",
"file_path": "foo/bar5",
"content": "new content"
},
{
"action": "chmod",
"file_path": "foo/bar5",
"execute_filemode": true
}
]
}
JSON
)
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --header "Content-Type: application/json" \
--data "$PAYLOAD" "https://gitlab.example.com/api/v4/projects/1/repository/commits"
How would I go about generating the actions if the files that are updated is variable. (I am committing via API to get around GPG signatures)