Files
aurbis/tasks/gitea_checkout.yml
T
2026-10-07 18:23:28 +02:00

61 lines
2.2 KiB
YAML

# 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)
- name: Give aurbis write access to {{ checkout_repo }}
file:
path: "{{ checkout_dest }}"
state: directory
recurse: true
group: aurbis
mode: g+rwX
- name: Make {{ checkout_repo }} directories hand their group to new files
ansible.builtin.command:
cmd: "find {{ checkout_dest }} -type d ! -perm -g+s -print -exec chmod g+s {} +"
register: checkout_setgid
changed_when: checkout_setgid.stdout != ""