system-config/playbooks/roles/gitea-set-org-logos/tasks/main.yaml
Clark Boylan 1654759865 Update gitea to 1.19.3
Gitea 1.19 is here. Release notes can be found at:

  https://github.com/go-gitea/gitea/blob/v1.19.3/CHANGELOG.md

I've highlighted the breaking changes entries in this commit message
with notes on whether or not this affects us.

* 1.19.0
  * Add loading yaml label template files (#22976) (#23232)
    * I think this is for auto applying labels to PRs? Shouldn't affect
      us.
  * Make issue and code search support camel case for Bleve (#22829)
    * We don't rely on code search in gitea yet, but this seems like a
      good addition.
  * Repositories: by default disable all units except code and pulls on forks (#22541)
    * We don't allow forks so this shouldn't affect us.
  * Support template for merge message description (#22248)
    * We don't do merging via gitea so this shouldn't affect us.
  * Remove ONLY_SHOW_RELEVANT_REPOS setting (#21962)
    * We don't set this flag in our app.ini config file.
  * Implement actions (#21937)
    * They are disabled by default, but I've explicitly disabled them as
      we use Zuul.
  * Remove deprecated DSA host key from Docker Container (#21522)
    * Our installatins were all created prior to this update which
      generated DSA keys. We can go and manually clean them up with
      gitea disabled if we like.
  * Improve valid user name check (#20136)
    * As long as our CI job is able to create the necessary accounts we
      should be fine.

* 1.19.1
  * Rename actions unit to repo.actions and add docs for it (#23733) (#23881)
    * app.ini.j2 updated to use repo.actions to disable the repo unit.

* 1.19.2
  * No breaking changes listed.

* 1.19.3
  * No breaking changes listed.

In addition to the breaking changes upstream has updated to golang 1.20
and nodejs 18. We update our image to match.

In 1.19.0 and 1.19.1 org listing required authentication which was a new
change/regression in [0] gitea. I have updated the logo update role to
drop authentication details to make it clear this API should be publicly
accessible. In earlier patchsets I was forcing basic auth due to another
bug [1] which is not correct as we expect this API to be public.
Updating the role this way makes that more clear.

Finally the usual template updates are applied to keep our forked
templates in line with upstream. There were no template changes between
1.19.0, 1.19.1, 1.19.2, and 1.19.3 according to git diff.

[0] https://github.com/go-gitea/gitea/issues/24159
[1] https://github.com/go-gitea/gitea/issues/24160

Change-Id: I5570deaf505a27c8c90c58896de990a4d2d44530
2023-05-03 14:42:08 -07:00

46 lines
1.4 KiB
YAML

- name: Get list of orgs
uri:
url: 'https://localhost:3000/api/v1/orgs'
method: GET
return_content: yes
validate_certs: false
status_code: 200
body_format: json
register: _org_list_raw
- 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 -T 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 }}'