shared gitea checkouts
This commit is contained in:
1 parent
fffc009ab9
commit
26449924b8
6 files changed
+79
-34
No files matched your search
@@ -0,0 +1,60 @@
|
||||
# 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 != ""
|
||||
Reference in new issue
Block a user