gitlab:通过API提交多个文件
我有一个在gitlab ci中运行的脚本,该脚本结帐了一个新的分支并运行“ NPM运行文档”。这是根据上次运行以来的更改来更新各种Markdown文件。如果有任何更改,脚本将进行更改并创建新的MR。 GitLab文档显示了多文件提交的示例,但您似乎必须知道哪些文件将会更改。
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"
如果更新的文件是可变的,我将如何生成操作。 (我正在通过API承诺围绕GPG签名)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论