Skip to content

Commit 8aca914

Browse files
authored
Use Ansible command module rather than shell to fix commits with quotes (') (#36)
1 parent 64928c4 commit 8aca914

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

playbook/playbook.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,22 @@
1414
state: directory
1515

1616
- name: Configure git author mail
17-
shell: git config --global user.email "{{ author_mail }}"
17+
command:
18+
argv: [git, config, --global, user.email, "{{ author_mail }}"]
1819

1920
- name: Configure git author name
20-
shell: git config --global user.name "{{ author_name }}"
21+
command:
22+
argv: [git, config, --global, user.name, "{{ author_name }}"]
2123

2224
- name: Login to github
23-
shell: echo "{{ gh_access_token }}" | gh auth login --with-token
25+
command:
26+
argv: [gh, auth, login, --with-token]
27+
stdin: "{{ gh_access_token }}"
2428
register: loginresult
2529
ignore_errors: yes
2630

2731
- name: Update repositories from templates
2832
include: "update_repo.yaml"
2933
with_items: "{{ repositories }}"
3034
loop_control:
31-
loop_var: operator
35+
loop_var: operator

playbook/update_repo.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
update: no
77

88
- name: Create new branch
9-
shell: git checkout -b {{ pr_branch_name }}
10-
args:
9+
command:
10+
argv: [git, checkout, -b, "{{ pr_branch_name }}"]
1111
chdir: "{{ work_dir }}/{{ operator.name }}"
1212

1313
# Check if anything was changed, if yes commit changes and create a pull request, otherwise skip rest of this play
@@ -75,23 +75,23 @@
7575
- name: Create PR if changes were performed
7676
block:
7777
- name: Stage all changes
78-
shell: git add .
79-
args:
78+
command:
79+
argv: [git, add, .]
8080
chdir: "{{ work_dir }}/{{ operator.name }}"
8181

8282
- name: Commit changes
83-
shell: git commit -a -m '{{ commit_message }}'
84-
args:
83+
command:
84+
argv: [git, commit, -a, -m, "{{ commit_message }}"]
8585
chdir: "{{ work_dir }}/{{ operator.name }}"
8686

8787
- name: Push changes
88-
shell: git push --set-upstream origin {{ pr_branch_name }}
89-
args:
88+
command:
89+
argv: [git, push, --set-upstream, origin, "{{ pr_branch_name }}"]
9090
chdir: "{{ work_dir }}/{{ operator.name }}"
9191

9292
- name: Create PR
93-
shell: gh pr create --base main --title "{{ pr_title }}" --body "{{ pr_body }} --reviewer "@stackabletech/developers""
94-
args:
93+
command:
94+
argv: [gh, pr, create, --base, main, --title, "{{ pr_title }}", --body, "{{ pr_body }}", --reviewer, "@stackabletech/developers"]
9595
chdir: "{{ work_dir }}/{{ operator.name }}"
9696

97-
when: directory_result.changed or template_result.changed or file_result.changed or deletion_result.changed
97+
when: directory_result.changed or template_result.changed or file_result.changed or deletion_result.changed

0 commit comments

Comments
 (0)