Merge "gitea: set custom avatars for orgs"
@ -6,3 +6,7 @@
|
||||
# Lookup runs locally on the calling machine, so doesn't need
|
||||
# project-config remotely
|
||||
projects: "{{ lookup('file', project_config_src + '/gerrit/projects.yaml') | from_yaml }}"
|
||||
|
||||
- name: Setup logos
|
||||
include_role:
|
||||
name: gitea-set-org-logos
|
||||
|
7
playbooks/roles/gitea-set-org-logos/README.rst
Normal file
@ -0,0 +1,7 @@
|
||||
Set custom logos for organisations in gitea
|
||||
|
||||
Note that logos should be a PNG file. We've standardised on a 400x400
|
||||
to keep it simple.
|
||||
|
||||
Images should respect the limits set by gitea; see
|
||||
`<https://docs.gitea.io/en-us/config-cheat-sheet/#picture-picture>`_
|
BIN
playbooks/roles/gitea-set-org-logos/files/airship.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
playbooks/roles/gitea-set-org-logos/files/default.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
playbooks/roles/gitea-set-org-logos/files/opendev.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
playbooks/roles/gitea-set-org-logos/files/openstack.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
playbooks/roles/gitea-set-org-logos/files/starlingx.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
playbooks/roles/gitea-set-org-logos/files/vexxhost.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
playbooks/roles/gitea-set-org-logos/files/zuul.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
48
playbooks/roles/gitea-set-org-logos/tasks/main.yaml
Normal file
@ -0,0 +1,48 @@
|
||||
- name: Get list of orgs
|
||||
uri:
|
||||
url: 'https://localhost:3000/api/v1/orgs'
|
||||
method: GET
|
||||
user: root
|
||||
password: '{{ gitea_root_password }}'
|
||||
return_content: yes
|
||||
validate_certs: false
|
||||
status_code: 200
|
||||
body_format: json
|
||||
register: _org_list_raw
|
||||
no_log: True
|
||||
|
||||
- name: Filter org list
|
||||
set_fact:
|
||||
_org_list: '{{ _org_list_raw.json | map(attribute="username") | list }}'
|
||||
|
||||
- name: Copy org logos
|
||||
copy:
|
||||
src: '{{ lookup("first_found", _org_logos) }}'
|
||||
dest: '/var/gitea/data/gitea/avatars/{{ item }}'
|
||||
owner: 1000
|
||||
group: 1000
|
||||
mode: 0644
|
||||
vars:
|
||||
_org_logos:
|
||||
- '{{ item }}.png'
|
||||
- 'default.png'
|
||||
loop: '{{ _org_list }}'
|
||||
register: _logos_updated
|
||||
|
||||
- name: Get changed logos
|
||||
set_fact:
|
||||
_changed_logos: '{{ _logos_updated.results | selectattr("changed", "equalto", true) | map(attribute="item") | list }}'
|
||||
|
||||
# NOTE(ianw) 2022-03-17 There is currently no API to update avatar
|
||||
# logos with gitea, so we direct update for now.
|
||||
# * orgs are just entries in the "users" table
|
||||
# * the "avatar" field is a plain-text name of a file in
|
||||
# /var/gitea/data/gitea/avatars
|
||||
- name: Run update query
|
||||
shell: >-
|
||||
/usr/local/bin/docker-compose -f /etc/gitea-docker/docker-compose.yaml
|
||||
exec mariadb bash -c 'mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e
|
||||
"USE gitea; UPDATE user SET avatar = '\''{{ item }}'\'', use_custom_avatar = 1 WHERE name = '\''{{ item }}'\''"'
|
||||
args:
|
||||
executable: '/bin/bash'
|
||||
loop: '{{ _changed_logos }}'
|
@ -93,7 +93,12 @@ def test_gitea_screenshots(host):
|
||||
('https://localhost:3081/opendev/system-config', None,
|
||||
'gitea-project-system-config.png'),
|
||||
('https://localhost:3081/opendev/disk-image-builder', None,
|
||||
'gitea-project-dib.png')
|
||||
'gitea-project-dib.png'),
|
||||
('https://localhost:3081/opendev/', None,
|
||||
'gitea-org-opendev.png'),
|
||||
('https://localhost:3081/explore/organizations', None,
|
||||
'gitea-org-expore.png'),
|
||||
)
|
||||
|
||||
take_screenshots(host, shots)
|
||||
|
||||
|