# Shared checkout of a gitea repo: root seeds and fast-forwards it over anonymous # https, aurbis members push and pull over ssh with their own gitea key. - name: Create {{ checkout_repo }} directory file: path: "{{ checkout_dest }}" state: directory owner: root group: aurbis mode: "02775" - name: Seed {{ checkout_repo }} ansible.builtin.git: repo: "{{ gitea_https }}/{{ checkout_repo }}.git" dest: "{{ checkout_dest }}" version: "{{ checkout_version | default('master') }}" update: false force: false - name: Point {{ checkout_repo }} origin at git-over-ssh community.general.git_config: name: remote.origin.url scope: local repo: "{{ checkout_dest }}" value: "{{ gitea_ssh }}:{{ checkout_repo }}.git" - name: Have git keep {{ checkout_repo }} group-writable community.general.git_config: name: core.sharedRepository scope: local repo: "{{ checkout_dest }}" value: group - name: Add {{ checkout_repo }} to safe.directory community.general.git_config: name: safe.directory scope: system add_mode: add value: "{{ checkout_dest }}" # ff-only, so unpushed commits or conflicting edits on the host fail the run instead of being lost. - name: Fast-forward {{ checkout_repo }} ansible.builtin.shell: chdir: "{{ checkout_dest }}" cmd: | set -e umask 002 before=$(git rev-parse HEAD) git fetch -q {{ gitea_https }}/{{ checkout_repo }}.git +refs/heads/{{ checkout_version | default('master') }}:refs/remotes/origin/{{ checkout_version | default('master') }} git merge -q --ff-only origin/{{ checkout_version | default('master') }} [ "$before" = "$(git rev-parse HEAD)" ] || echo updated register: checkout_pull changed_when: "'updated' in checkout_pull.stdout" when: checkout_update | default(true) - import_tasks: aurbis_tree.yml vars: tree_path: "{{ checkout_dest }}"