|
111 | 111 | register: git_change |
112 | 112 | failed_when: git_change.rc == 0 # fail when there are no changes |
113 | 113 |
|
| 114 | + - name: Configure git author mail |
| 115 | + command: |
| 116 | + argv: [git, config, user.email, "{{ author_mail }}"] |
| 117 | + chdir: "{{ work_dir }}/{{ operator.name }}" |
114 | 118 |
|
115 | | -# Check if anything was changed, if yes commit changes and create a pull request, otherwise skip rest of this play |
116 | | -- name: "Operator [{{ operator.name }}] create PR if changes were performed" |
117 | | - block: |
118 | | - - name: "Operator [{{ operator.name }}] run 'git ls-remotes' to ensure that the branch {{ pr_branch_name }} doesn't exist" |
| 119 | + - name: Configure git author name |
119 | 120 | command: |
120 | | - argv: [git, ls-remote, --exit-code, --heads, "https://{{ gh_access_token }}@github.com/{{ operator.url }}", "{{ pr_branch_name }}"] |
| 121 | + argv: [git, config, user.name, "{{ author_name }}"] |
121 | 122 | chdir: "{{ work_dir }}/{{ operator.name }}" |
122 | | - register: branch_exists |
123 | | - failed_when: branch_exists.rc != 2 # fail when branch exists |
124 | 123 |
|
125 | 124 | - name: "Operator [{{ operator.name }}] stage all changes" |
126 | 125 | command: |
|
129 | 128 |
|
130 | 129 | - name: "Operator [{{ operator.name }}] commit changes" |
131 | 130 | command: |
132 | | - argv: [git, commit, -a, -m, "{{ commit_message }}"] |
| 131 | + argv: [git, commit, -m, "{{ commit_message }}"] |
133 | 132 | chdir: "{{ work_dir }}/{{ operator.name }}" |
134 | 133 |
|
| 134 | +# Fail if the remote branch exists, otherwise push changes and create a pull request |
| 135 | +- name: "Operator [{{ operator.name }}] create PR if changes were performed" |
| 136 | + block: |
| 137 | + - name: "Operator [{{ operator.name }}] run 'git ls-remotes' to ensure that the branch {{ pr_branch_name }} doesn't exist" |
| 138 | + command: |
| 139 | + argv: [git, ls-remote, --exit-code, --heads, "https://{{ gh_access_token }}@github.com/{{ operator.url }}", "{{ pr_branch_name }}"] |
| 140 | + chdir: "{{ work_dir }}/{{ operator.name }}" |
| 141 | + register: branch_exists |
| 142 | + failed_when: branch_exists.rc != 2 # fail when branch exists |
| 143 | + |
135 | 144 | - name: "Operator [{{ operator.name }}] push changes to branch {{ pr_branch_name }}" |
136 | 145 | command: |
137 | 146 | argv: [git, push, --set-upstream, origin, "{{ pr_branch_name }}"] |
|
0 commit comments