diff --git a/README.md b/README.md index 7eb7418..50677a4 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,7 @@ gitea_download_url: 'https://github.com/go-gitea/gitea/releases/download/v{{ git ## Playbook The playbook includes postgresql role and deploys entire stack needed to run Gitea. Additional roles are also available in the Ansible roles repos in git. +## Customization +Check https://docs.gitea.io/en-us/customizing-gitea/ + +You can deploy custom themes with this role. To do so, check `gitea_custom_themes` var and add your theme's repo address there. The root path of the theme repo must have a `css` folder that includes the theme's css files. You can check https://git.disroot.org/Disroot-themes/forgejo-beetroot as an example. diff --git a/defaults/main.yml b/defaults/main.yml index 384edf4..9a15fa0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -11,8 +11,14 @@ gitea_version: '1.18.3-2' gitea_arch: 'linux-amd64' #gitea_download_url: 'https://github.com/go-gitea/gitea/releases/download/v{{ gitea_version }}/gitea-{{ gitea_version }}-{{ gitea_arch }}' -#[CONFIG] +#Uncomment below if you want to add custom themes +#gitea_theme_dir: '{{ gitea_lib_dir }}/custom' +#gitea_custom_themes: +# - name: 'beetroot' #add name of the theme +# repo: 'https://git.disroot.org/Disroot-themes/forgejo-beetroot.git' #add git repository of the theme +# img: 'true' #set it to true if there is an img folder +#[CONFIG] # App.ini file variables gitea_base_config: - 'APP_NAME = Gitea: Git with a cup of tea' @@ -23,7 +29,7 @@ gitea_oauth2_config: - 'JWT_SECRET = ' #41 random chars gitea_ui_config: - - 'THEMES = auto,arc-green,gitea' + - 'THEMES = auto,arc-green,gitea,beetroot-auto,beetroot-light,beetroot-dark,' - 'DEFAULT_THEME = arc-green' gitea_security_config: diff --git a/tasks/configure.yml b/tasks/configure.yml index 55990ef..2de78d3 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -42,3 +42,5 @@ dest: "{{ gitea_confdir }}" owner: "{{ gitea_user }}" group: "{{ gitea_group }}" + notify: Restart gitea + tags: config \ No newline at end of file diff --git a/tasks/custom_themes.yml b/tasks/custom_themes.yml new file mode 100644 index 0000000..3385a81 --- /dev/null +++ b/tasks/custom_themes.yml @@ -0,0 +1,51 @@ +--- + +- name: '[THEME] - Create public dir' + file: + path: '{{ gitea_lib_dir }}/custom/public/' + state: directory + owner: "{{ gitea_user }}" + group: "{{ gitea_group }}" + tags: theme + +- name: "[THEME] - Get repo" + git: + repo: "{{ item.repo }}" + dest: "{{ gitea_theme_dir }}/{{ item.name }}" + loop: "{{ gitea_custom_themes }}" + tags: theme + +- name: "[THEME] - Sync css folder" + synchronize: + src: "{{ gitea_theme_dir }}/{{ item.name }}/css/" + dest: "{{ gitea_lib_dir }}/custom/public/css" + owner: yes + group: yes + recursive: yes + delete: false + delegate_to: "{{ inventory_hostname }}" + loop: "{{ gitea_custom_themes }}" + tags: theme + +- name: "[THEME] - Sync img folder" + synchronize: + src: "{{ gitea_theme_dir }}/{{ item.name }}/img/" + dest: "{{ gitea_lib_dir }}/custom/public/img" + owner: yes + group: yes + recursive: yes + delete: false + delegate_to: "{{ inventory_hostname }}" + when: item.img == "true" + loop: "{{ gitea_custom_themes }}" + tags: theme + +- name: "[THEME] - Change repo ownership" + file: + path: "{{ gitea_lib_dir }}/custom" + state: directory + recurse: yes + owner: "{{ gitea_user }}" + group: "{{ gitea_group }}" + tags: theme + diff --git a/tasks/main.yml b/tasks/main.yml index acd8dc3..d3a360a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,6 +5,12 @@ - name: "[GITEA] - configure" include_tasks: configure.yml + tags: config + +- name: "[GITEA] - theme" + include_tasks: custom_themes.yml + when: gitea_custom_themes is defined + tags: theme - name: "[GITEA] - systemd" include_tasks: systemd.yml