diff --git a/.github/collection_index.md.j2 b/.github/collection_index.md.j2 index bfd8e63..e86e883 100644 --- a/.github/collection_index.md.j2 +++ b/.github/collection_index.md.j2 @@ -1,7 +1,8 @@ --- layout: default -title: {{ collection_name }} +title: {{ collection_namespace }}.{{ collection_name }} has_children: true +nav_order: {{ (nav_order | default(-2)) + 2 }} --- # {{ collection_name }} \ No newline at end of file diff --git a/.github/fix_readme.yml b/.github/fix_readme.yml index 02589fb..2507f6b 100644 --- a/.github/fix_readme.yml +++ b/.github/fix_readme.yml @@ -1,12 +1,11 @@ --- -- name: Set collections +- name: Set roles ansible.builtin.set_fact: roles_list: [] - r_roles: [] -- name: Get collections +- name: Get roles ansible.builtin.find: - path: "{{ r_tempfile.path }}/{{ outer_item }}/roles/" + path: "{{ r_tempfile.path }}/{{ collection.name }}/roles/" file_type: directory register: r_roles @@ -17,14 +16,14 @@ - name: Cleanup readme ansible.builtin.lineinfile: - path: "{{ r_tempfile['path'] }}/{{ outer_item }}/roles/{{ item }}/README.md" + path: "{{ r_tempfile['path'] }}/{{ collection.name }}/roles/{{ item }}/README.md" regex: '---' state: absent loop: "{{ roles_list }}" - name: Remove join(',') that causes issues ansible.builtin.replace: - path: "{{ r_tempfile['path'] }}/{{ outer_item }}/roles/{{ item }}/README.md" + path: "{{ r_tempfile['path'] }}/{{ collection.name }}/roles/{{ item }}/README.md" regexp: "{{ _regex }}" replace: '' loop: "{{ roles_list }}" @@ -33,19 +32,20 @@ - name: Update readme ansible.builtin.lineinfile: - path: "{{ r_tempfile['path'] }}/{{ outer_item }}/roles/{{ item }}/README.md" + path: "{{ r_tempfile['path'] }}/{{ collection.name }}/roles/{{ item }}/README.md" insertbefore: BOF line: | --- layout: default - parent: {{ outer_item }} + title: {{ item }} + parent: {{ collection.namespace }}.{{ collection.name }} --- loop: "{{ roles_list }}" - name: Copy and rename readme ansible.builtin.copy: - src: "{{ r_tempfile['path'] }}/{{ outer_item }}/roles/{{ item }}/README.md" - dest: "../collections/{{ outer_item }}/{{ item }}.md" + src: "{{ r_tempfile['path'] }}/{{ collection.name }}/roles/{{ item }}/README.md" + dest: "../collections/{{ collection.name }}/{{ item }}.md" remote_src: true mode: "0644" loop: "{{ roles_list }}" @@ -53,8 +53,9 @@ - name: Create collection index page ansible.builtin.template: src: collection_index.md.j2 - dest: "../collections/{{ outer_item }}/index.md" + dest: "../collections/{{ collection.name }}/index.md" mode: "0644" vars: - collection_name: "{{ outer_item }}" + collection_name: "{{ collection.name }}" + collection_namespace: "{{ collection.namespace }}" ... diff --git a/.github/playbook.yml b/.github/playbook.yml index 3ed6e8f..94df22b 100644 --- a/.github/playbook.yml +++ b/.github/playbook.yml @@ -3,6 +3,23 @@ hosts: localhost connection: local gather_facts: false + vars: + collection_list: + - name: controller_configuration + namespace: infra + repo: https://github.com/redhat-cop/controller_configuration.git + - name: ah_configuration + namespace: infra + repo: https://github.com/ansible/galaxy_collection.git + - name: eda_configuration + namespace: infra + repo: https://github.com/redhat-cop/eda_configuration.git + - name: aap_utilities + namespace: infra + repo: https://github.com/redhat-cop/aap_utilities.git + - name: ee_utilities + namespace: infra + repo: https://github.com/redhat-cop/ee_utilities.git tasks: - name: Delete directories ansible.builtin.file: @@ -18,15 +35,10 @@ - name: Create sub directories ansible.builtin.file: - path: "../collections/{{ item }}" + path: "../collections/{{ item.name }}" state: directory mode: "0755" - loop: - - controller_configuration - - galaxy_collection - - eda_configuration - - aap_utilities - - ee_utilities + loop: "{{ collection_list }}" - name: Create temporary direcotry ansible.builtin.tempfile: @@ -36,125 +48,23 @@ - name: Create temporary directories ansible.builtin.file: - path: "{{ r_tempfile['path'] }}/{{ item }}" + path: "{{ r_tempfile['path'] }}/{{ item.name }}" state: directory mode: "0755" - loop: - - controller_configuration - - galaxy_collection - - eda_configuration - - aap_utilities - - ee_utilities - - - name: Clone controller_configuration - ansible.builtin.git: - repo: https://github.com/redhat-cop/controller_configuration.git - dest: "{{ r_tempfile['path'] }}/controller_configuration/" - single_branch: true - version: devel - - - name: Clone galaxy_collection - ansible.builtin.git: - repo: https://github.com/ansible/galaxy_collection.git - dest: "{{ r_tempfile['path'] }}/galaxy_collection" - single_branch: true - version: devel - - - name: Clone eda_configuration - ansible.builtin.git: - repo: https://github.com/redhat-cop/eda_configuration.git - dest: "{{ r_tempfile['path'] }}/eda_configuration" - single_branch: true - version: devel - - - name: Clone aap_utilities - ansible.builtin.git: - repo: https://github.com/redhat-cop/aap_utilities.git - dest: "{{ r_tempfile['path'] }}/aap_utilities" - single_branch: true - version: devel + loop: "{{ collection_list }}" - - name: Clone ee_utilities + - name: Clone collections ansible.builtin.git: - repo: https://github.com/redhat-cop/ee_utilities.git - dest: "{{ r_tempfile['path'] }}/ee_utilities" + repo: "{{ item.repo }}" + dest: "{{ r_tempfile['path'] }}/{{ item.name }}/" single_branch: true version: devel - - - name: Get collections - ansible.builtin.find: - path: "{{ r_tempfile.path }}" - file_type: directory - register: r_directories - - - name: Set collections - ansible.builtin.set_fact: - collection_list: "{{ collection_list | default([]) + [item | ansible.builtin.basename] }}" - loop: "{{ r_directories['files'] | map(attribute='path') | flatten }}" + loop: "{{ collection_list }}" - name: Loop through each collection ansible.builtin.include_tasks: fix_readme.yml loop: "{{ collection_list }}" loop_control: - loop_var: outer_item - - - name: Get list of files controller_config - ansible.builtin.find: - path: ../collections/controller_configuration - file_type: file - patterns: '*.md' - register: r_controller_config - - - name: Set file names controller_config - ansible.builtin.set_fact: - controller_config: "{{ controller_config | default([]) + [item | ansible.builtin.basename] }}" - loop: "{{ r_controller_config['files'] | map(attribute='path') | flatten }}" - - - name: Get list of files galaxy_collection - ansible.builtin.find: - path: ../collections/galaxy_collection - file_type: file - patterns: '*.md' - register: r_galaxy_collection - - - name: Set file names galaxy_collection - ansible.builtin.set_fact: - galaxy_collection: "{{ galaxy_collection | default([]) + [item | ansible.builtin.basename] }}" - loop: "{{ r_galaxy_collection['files'] | map(attribute='path') | flatten }}" - - - name: Get list of files eda_config - ansible.builtin.find: - path: ../collections/eda_configuration - file_type: file - patterns: '*.md' - register: r_eda_config - - - name: Set file names eda_config - ansible.builtin.set_fact: - eda_config: "{{ eda_config | default([]) + [item | ansible.builtin.basename] }}" - loop: "{{ r_eda_config['files'] | map(attribute='path') | flatten }}" - - - name: Get list of files aap_utilities - ansible.builtin.find: - path: ../collections/aap_utilities - file_type: file - patterns: '*.md' - register: r_aap_utilities - - - name: Set file names aap_utilities - ansible.builtin.set_fact: - aap_utilities: "{{ aap_utilities | default([]) + [item | ansible.builtin.basename] }}" - loop: "{{ r_aap_utilities['files'] | map(attribute='path') | flatten }}" - - - name: Get list of files ee_utilities - ansible.builtin.find: - path: ../collections/ee_utilities - file_type: file - patterns: '*.md' - register: r_ee_utilities - - - name: Set file names ee_utilities - ansible.builtin.set_fact: - ee_utilities: "{{ ee_utilities | default([]) + [item | ansible.builtin.basename] }}" - loop: "{{ r_ee_utilities['files'] | map(attribute='path') | flatten }}" + loop_var: collection + index_var: nav_order ...