kestra-io / plugin-git

Apache License 2.0
3 stars 4 forks source link

Raise an error when trying to push to a protected branch without sufficient permissions #88

Open anna-geller opened 3 months ago

anna-geller commented 3 months ago

Issue description

Issue reported via Slack:

"We use GitLab and wanted to sync flows to it. Long story short, the default branch we use is protected and allows only maintainers to push. I created an Access Token with developer access and tried to run the Push Flow task. it was going through good, no errors. But nothing appeared in git. I figured it was an issue with permissions to push to the branch. It would be great if the PushFlows task would drop an error instead of finishing it successfully. flow code i used:"

id: push_to_git
namespace: system

tasks:
  - id: commit_and_push
    type: io.kestra.plugin.git.PushFlows
    sourceNamespace: xxxxx.dev # the namespace from which flows are pushed
    targetNamespace: xxxxx.dev # the target production namespace; if different than sourceNamespace, the sourceNamespace in the source code will be overwritten by the targetNamespace
    flows: "*"  # optional list of glob patterns; by default, all flows are pushed
    includeChildNamespaces: true # optional boolean, false by default
    gitDirectory: _flows
    url: https://gitlab.com/xxxxx/xxxxx/kestra-flows # required string
    username: "{{ namespace.git_username }}" # required string needed for Auth with Git
    password: "{{ namespace.git_password }}"
    branch: develop # optional, uses "kestra" by default
    commitMessage: "add flows {{ now() }}"