To be merged when deploying to prod. Co-authored-by: muppeth <muppeth@disroot.org> Reviewed-on: #51 Reviewed-by: muppeth <muppeth@no-reply@disroot.org> Co-authored-by: meaz <meaz@disroot.org> Co-committed-by: meaz <meaz@disroot.org>
79 lines
No EOL
2.3 KiB
YAML
79 lines
No EOL
2.3 KiB
YAML
---
|
|
|
|
- name: '[THEME] - Create css dir'
|
|
file:
|
|
path: '{{ forgejo_theme_dir }}/public/assets/css'
|
|
state: directory
|
|
owner: "{{ forgejo_user }}"
|
|
group: "{{ forgejo_group }}"
|
|
tags: theme
|
|
|
|
# First, remove the css files from public folder, then theme repos
|
|
- name: "[THEME] - Remove css files from the css folder"
|
|
shell:
|
|
cmd: find "{{ forgejo_theme_dir }}/{{ item.name }}" -type f -name "*.css" -printf "%f\n" | xargs -I{} rm public/assets/css/{}
|
|
chdir: "{{ forgejo_theme_dir }}"
|
|
loop: "{{ forgejo_custom_themes }}"
|
|
when: item.enable == 'false'
|
|
tags: theme
|
|
|
|
- name: "[THEME] - Remove theme repo"
|
|
file:
|
|
path: "{{ forgejo_theme_dir }}/{{ item.name }}"
|
|
state: absent
|
|
owner: "{{ forgejo_user }}"
|
|
group: "{{ forgejo_group }}"
|
|
loop: "{{ forgejo_custom_themes }}"
|
|
when: item.enable == 'false'
|
|
tags: theme
|
|
|
|
# Second, get theme repos and deploy css files in public folder
|
|
- name: "[THEME] - Get repo"
|
|
git:
|
|
repo: "{{ item.repo }}"
|
|
dest: "{{ forgejo_theme_dir }}/{{ item.name }}"
|
|
force: yes
|
|
loop: "{{ forgejo_custom_themes }}"
|
|
when: item.enable == 'true'
|
|
become: true
|
|
become_user: "{{ forgejo_user }}"
|
|
tags: theme
|
|
|
|
- name: "[THEME] - Find css files from different repos"
|
|
find:
|
|
paths: "{{ forgejo_theme_dir }}"
|
|
patterns: ".*(?<!\\.min)\\.css$"
|
|
recurse: yes
|
|
use_regex: yes
|
|
register: css_files
|
|
tags: theme
|
|
|
|
- name: "[THEME] - Copy css files to the public folder"
|
|
copy:
|
|
src: "{{ item.path }}"
|
|
dest: "{{ forgejo_theme_dir }}/public/assets/css/"
|
|
remote_src: yes
|
|
force: yes
|
|
mode: '0644'
|
|
with_items: "{{ css_files.files }}"
|
|
when: "'/public/' not in item.path"
|
|
become: true
|
|
become_user: "{{ forgejo_user }}"
|
|
tags: theme
|
|
|
|
|
|
# Lastly, update app.ini by adding the theme's name list.
|
|
- name: "[THEME] - Get and prepare a list for app.ini of css files in public folder, register it"
|
|
shell:
|
|
cmd: ls "{{ forgejo_theme_dir }}/public/assets/css" | awk '{ if ($0 ~ /^theme-/) { gsub(/^theme-/, "", $0) }; gsub(/.css$/, "", $0); print }' | paste -s -d,
|
|
chdir: "{{ forgejo_theme_dir }}"
|
|
register: theme_name
|
|
tags: theme
|
|
|
|
- name: "[THEME] - Add list of themes in app.ini"
|
|
lineinfile:
|
|
path: "{{ forgejo_confdir }}"
|
|
regexp: '^THEMES'
|
|
line: "{{ forgejo_ui_config[0] }},{{ theme_name.stdout }}"
|
|
notify: Restart forgejo
|
|
tags: theme |