From 38599ae607e9ac29dcd5d54fa1efd408cba90017 Mon Sep 17 00:00:00 2001 From: L3D Date: Sat, 21 Oct 2023 02:16:13 +0200 Subject: [PATCH 1/2] andding jinja2 linter and improve template + update yamllint + update ansible-lint + add j2lint + lint j2 template --- .github/workflows/ansible-linting-check.yml | 9 ++++--- .github/workflows/j2lint-check.yml | 22 ++++++++++++++++ .github/workflows/yamllint-check.yml | 22 ++++++++++++++++ README.md | 9 +++---- requirements.yml | 4 +++ templates/gitea.ini.j2 | 28 ++++++++++----------- vars/main.yml | 2 +- 7 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/j2lint-check.yml create mode 100644 .github/workflows/yamllint-check.yml create mode 100644 requirements.yml diff --git a/.github/workflows/ansible-linting-check.yml b/.github/workflows/ansible-linting-check.yml index 9ad66de..949c09a 100644 --- a/.github/workflows/ansible-linting-check.yml +++ b/.github/workflows/ansible-linting-check.yml @@ -11,14 +11,15 @@ jobs: steps: - name: 'checkout git repo' - uses: actions/checkout@v4.1.0 + uses: actions/checkout@v4.1.1 with: lfs: true - submodules: false + submodules: true fetch-depth: 0 - name: Run ansible-lint - uses: ansible-actions/ansible-lint-action@v0.0.3 + uses: ansible-actions/ansible-lint-action@v1.0.1 with: target: "./" - python_dependency: "jmespath" + collections_yml: 'requirements.yml' + python_dependency: 'jmespath' diff --git a/.github/workflows/j2lint-check.yml b/.github/workflows/j2lint-check.yml new file mode 100644 index 0000000..5037de5 --- /dev/null +++ b/.github/workflows/j2lint-check.yml @@ -0,0 +1,22 @@ +--- +name: Jinja2 Linting check + +# yamllint disable-line rule:truthy +on: [push, pull_request] + +jobs: + build: + name: Jinja2 Linting + runs-on: ubuntu-latest + + steps: + - name: 'checkout git repo' + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - name: Run j2lint + uses: ansible-actions/j2lint-action@v0.0.1 + with: + target: "./" diff --git a/.github/workflows/yamllint-check.yml b/.github/workflows/yamllint-check.yml new file mode 100644 index 0000000..751e992 --- /dev/null +++ b/.github/workflows/yamllint-check.yml @@ -0,0 +1,22 @@ +--- +name: Yamllint check + +# yamllint disable-line rule:truthy +on: [push, pull_request] + +jobs: + build: + name: Yamllint + runs-on: ubuntu-latest + + steps: + - name: 'checkout git repo' + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - name: Run yamllint + uses: ansible-actions/yamllint-action@v0.0.1 + with: + target: "./" diff --git a/README.md b/README.md index fa6928b..f1df09c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Ansible Galaxy](https://ansible.l3d.space/svg/l3d.gitea.svg)](https://galaxy.ansible.com/l3d/gitea) +[![Ansible Galaxy](https://ansible.l3d.space/svg/l3d.gitea.svg)](https://galaxy.ansible.com/ui/standalone/roles/l3d/gitea/) [![BSD-3 Clause](https://ansible.l3d.space/svg/l3d.gitea_license.svg)](LICENSE) [![Maintainance](https://ansible.l3d.space/svg/l3d.gitea_maintainance.svg)](https://ansible.l3d.space/#l3d.gitea) @@ -15,7 +15,7 @@ This role is also Part of the Ansible-Collection [l3d.git](https://galaxy.ansibl The following code has been tested with the latest Debian Stable, it should work on Ubuntu and RedHat as well. ```yaml -# ansible-galaxy install l3d.gitea +# ansible-galaxy role install l3d.gitea - name: "Install gitea" hosts: git.example.com @@ -385,11 +385,10 @@ This role uses the ``ansible.builtin`` and ``community.general`` ansible Collect ### Galaxy Collections + community.general - ### Example requirements Installation ``` -ansible-galaxy install community.general -pip3 install jmespath +ansible-galaxy collection install --update --role-file requirements.yml +pip3 install --update jmespath ``` ## Contribute diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..2159e44 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,4 @@ +--- +collections: + - name: community.general + source: https://galaxy.ansible.com diff --git a/templates/gitea.ini.j2 b/templates/gitea.ini.j2 index 705a1f7..e4bea98 100644 --- a/templates/gitea.ini.j2 +++ b/templates/gitea.ini.j2 @@ -1,8 +1,8 @@ -; this file is the configuration of your local gitea instance +; this file is the configuration of your local Gitea instance ; {{ ansible_managed }} ; -; This file overwrites the default values from gitea. -; undefined variables will use the default value from gitea. +; This file overwrites the default values from Gitea. +; undefined variables will use the default value from Gitea. ; Cheat Sheet: https://docs.gitea.com/next/administration/config-cheat-sheet/ ; ; -> https://docs.gitea.com/next/administration/config-cheat-sheet#overall-default @@ -90,7 +90,7 @@ APP_DATA_PATH = {{ gitea_home }}/data PROTOCOL = {{ gitea_protocol }} DOMAIN = {{ gitea_http_domain }} ROOT_URL = {{ gitea_root_url }} -HTTP_ADDR = {{ gitea_http_listen }} +HTTP_ADDR = {{ gitea_http_listen }} HTTP_PORT = {{ gitea_http_port }} START_SSH_SERVER = {{ gitea_start_ssh | ternary('true', 'false') }} SSH_DOMAIN = {{ gitea_ssh_domain }} @@ -102,7 +102,7 @@ CERT_FILE = {{ gitea_tls_cert_file }} KEY_FILE = {{ gitea_tls_key_file }} {% endif %} LANDING_PAGE = {{ gitea_landing_page }} -{% if gitea_lfs_server_enabled | bool -%} +{% if gitea_lfs_server_enabled | bool %} LFS_START_SERVER = true LFS_JWT_SECRET = {{ gitea_lfs_jwt_secret }} {% endif %} @@ -110,9 +110,9 @@ REDIRECT_OTHER_PORT = {{ gitea_redirect_other_port | ternary('true', 'false') }} PORT_TO_REDIRECT = {{ gitea_port_to_redirect }} ENABLE_ACME = {{ gitea_enable_acme | ternary('true', 'false') }} {% if gitea_enable_acme | bool %} -{% if gitea_acme_url != '' %} +{% if gitea_acme_url != '' %} ACME_URL = {{ gitea_acme_url }} -{% endif %} +{% endif %} ACME_ACCEPTTOS = {{ gitea_acme_accepttos | ternary('true', 'false') }} ACME_DIRECTORY = {{ gitea_acme_directory }} ACME_EMAIL = {{ gitea_acme_email }} @@ -194,14 +194,14 @@ ALLOW_ONLY_EXTERNAL_REGISTRATION = {{ gitea_allow_only_external_registration | t [mailer] ENABLED = {{ gitea_mailer_enabled | ternary('true', 'false') }} {% if gitea_mailer_enabled | bool %} +{% if gitea_mailer_use_client_cert | bool %} +CLIENT_CERT_FILE = {{ gitea_mailer_client_cert_file }} +CLIENT_KEY_FILE = {{ gitea_mailer_client_key_file }} +{% endif %} PROTOCOL = {{ gitea_mailer_protocol }} SMTP_ADDR = {{ gitea_mailer_smtp_addr }} SMTP_PORT = {{ gitea_mailer_smtp_port }} USE_CLIENT_CERT = {{ gitea_mailer_use_client_cert | ternary('true', 'false') }} -{% if gitea_mailer_use_client_cert | bool %} -CLIENT_CERT_FILE = {{ gitea_mailer_client_cert_file }} -CLIENT_KEY_FILE = {{ gitea_mailer_client_key_file }} -{% endif %} FORCE_TRUST_SERVER_CERT = {{ gitea_mailer_force_trust_server_cert | ternary('true', 'false') }} USER = {{ gitea_mailer_user }} PASSWD = {{ gitea_mailer_password }} @@ -305,8 +305,8 @@ SHOW_FOOTER_VERSION = {{ gitea_other_show_footer_version | ternary('true', 'fals SHOW_FOOTER_TEMPLATE_LOAD_TIME = {{ gitea_other_show_footer_template_load_time | ternary('true', 'false') }} ENABLE_SITEMAP = {{ gitea_other_enable_sitemap | ternary('true', 'false') }} ENABLE_FEED = {{ gitea_other_enable_feed | ternary('true', 'false') }} -; -; -; +; +; +; ; Optional additional config {{ gitea_extra_config }} diff --git a/vars/main.yml b/vars/main.yml index d6abe74..ba8f195 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -62,5 +62,5 @@ transfer_custom_footer: - 'files/gitea_footer/extra_links_footer.tmpl' - 'files/extra_links_footer.tmpl' -playbook_version_number: 51 # should be int +playbook_version_number: 52 # should be int playbook_version_path: 'do1jlr.gitea.version' From aa749c5faf9a77c03ea11c325640ef4d5db39d28 Mon Sep 17 00:00:00 2001 From: L3D Date: Sat, 21 Oct 2023 02:18:56 +0200 Subject: [PATCH 2/2] only push releases to galaxy --- .github/workflows/galaxy.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/galaxy.yml b/.github/workflows/galaxy.yml index 4426496..0b12f52 100644 --- a/.github/workflows/galaxy.yml +++ b/.github/workflows/galaxy.yml @@ -3,8 +3,6 @@ name: Galaxy release # yamllint disable-line rule:truthy on: - push: - branches: ['main'] release: types: ['created']