File tree Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ Role tasks:
2626| sg_repository | * undefined* | No | Initial repository name. Mandatory if an external repository to mirror (sg_repo_mirror_url) is set.
2727| sg_repo_branch | main | No | Main branch in the initial repository
2828| sg_repo_mirror_url | * undefined* | No | Git URL to mirror into the initial repository
29- | sg_repo_mirror_branch | main | No | Branch to mirror from the repository
3029| sg_repo_sshkey | * undefined* | No | The sshkey to clone the initial repository when the repo requires ssh authentication.
3130
3231## Role requirements
Original file line number Diff line number Diff line change @@ -3,6 +3,5 @@ sg_namespace: gitea
33sg_action : install
44sg_gitea_image : mirror.gcr.io/gitea/gitea:latest-rootless
55sg_repo_branch : main
6- sg_repo_mirror_branch : main
76sg_url : http://localhost:3000
87...
Original file line number Diff line number Diff line change 1616 delay : 5
1717 until : _sg_gitea_namespace.resources | length == 0
1818
19- - name : Clear mirror temp dir
20- ansible.builtin.file :
21- path : " {{ _sg_mirror_repo.path }}"
22- state : absent
2319...
Original file line number Diff line number Diff line change 155155 ansible.builtin.git :
156156 dest : " {{ _sg_mirror_repo.path }}/mirror"
157157 repo : " {{ sg_repo_mirror_url }}"
158- version : " {{ sg_repo_mirror_branch }}"
158+ version : " {{ sg_repo_branch }}"
159159 key_file : " {{ keyfile | length | ternary(keyfile, omit) }}"
160160
161- - name : Mirror the repository # noqa command-instead-of-module
161+ - name : Mirror all branches to the repository # noqa command-instead-of-module
162162 ansible.builtin.shell :
163163 cmd : |
164- /usr/bin/git push http://{{ sg_username }}:{{ sg_password }}@{{ sg_gitea_domain }}/{{ sg_username }}/{{ sg_repository }}.git {{ sg_repo_mirror_branch }}:{{ sg_repo_branch }}
164+ /usr/bin/git remote add mirror http://{{ sg_username }}:{{ sg_password }}@{{ sg_gitea_domain }}/{{ sg_username }}/{{ sg_repository }}.git
165+ /usr/bin/git push mirror 'refs/remotes/origin/*:refs/heads/*'
165166 chdir : " {{ _sg_mirror_repo.path }}/mirror"
166- changed_when : false
167+ register : _sg_git_push_result
168+ failed_when : _sg_git_push_result.rc != 0
169+ changed_when : " 'Everything up-to-date' not in _sg_git_push_result.stderr"
167170 no_log : true
171+
172+ - name : Clear mirror temp dir
173+ ansible.builtin.file :
174+ path : " {{ _sg_mirror_repo.path }}"
175+ state : absent
176+
168177...
You can’t perform that action at this time.
0 commit comments