From 4f7acc73a45e7603324027e55910aeae3351c6d3 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 11:32:02 -0500 Subject: [PATCH 01/13] create dir --- .../internal/gha_docs/roles/generate/tasks/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml b/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml index 45c892c..06fb549 100644 --- a/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml +++ b/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml @@ -3,6 +3,12 @@ set_fact: _src: "{{ lookup('ansible.builtin.file', file) | from_yaml }}" +- name: Ensure output dir exists + ansible.builtin.file: + path: '{{ output }}' + state: directory + mode: '644' + - name: Template the workflow docs when: type == 'workflow' vars: From 81d8781e22c19397c79493d71c894fb36743ace6 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 11:32:49 -0500 Subject: [PATCH 02/13] test workflow --- .github/workflows/generate-wiki-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate-wiki-docs.yml b/.github/workflows/generate-wiki-docs.yml index 57cfbf3..f784d57 100644 --- a/.github/workflows/generate-wiki-docs.yml +++ b/.github/workflows/generate-wiki-docs.yml @@ -2,7 +2,7 @@ name: Generate Wiki Docs on: push: - branches: [main] + branches: [main, 'content-docs/generate-fixups'] paths: - .github/workflows/_shared* - .github/workflows/generate-wiki-docs.yml From 9b7887b0f30e5cadebd6223e40c6a7ad62d392af Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 11:33:56 -0500 Subject: [PATCH 03/13] dirname --- .../internal/gha_docs/roles/generate/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml b/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml index 06fb549..23bf4ea 100644 --- a/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml +++ b/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml @@ -5,7 +5,7 @@ - name: Ensure output dir exists ansible.builtin.file: - path: '{{ output }}' + path: '{{ output | dirname }}' state: directory mode: '644' From 08c9e21ce3a0ef275bfd2101cd84fe216a3be683 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 11:40:18 -0500 Subject: [PATCH 04/13] add path to trigger --- .github/workflows/generate-wiki-docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/generate-wiki-docs.yml b/.github/workflows/generate-wiki-docs.yml index f784d57..f541f46 100644 --- a/.github/workflows/generate-wiki-docs.yml +++ b/.github/workflows/generate-wiki-docs.yml @@ -6,6 +6,7 @@ on: paths: - .github/workflows/_shared* - .github/workflows/generate-wiki-docs.yml + - .internal/ansible/** - actions/**/action.yml jobs: From a48d9e3f124ed4ce44e8bdedfddfb00a151a550c Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 11:43:08 -0500 Subject: [PATCH 05/13] move trailing slash --- .github/workflows/generate-wiki-docs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate-wiki-docs.yml b/.github/workflows/generate-wiki-docs.yml index f541f46..9d65b08 100644 --- a/.github/workflows/generate-wiki-docs.yml +++ b/.github/workflows/generate-wiki-docs.yml @@ -12,8 +12,7 @@ on: jobs: generate: env: - # this path is going to be used with rsync, it MUST end in a forward slash [/] - WIKI: ${{ github.workspace }}/wiki/ + WIKI: ${{ github.workspace }}/wiki ANSIBLE_COLLECTIONS_PATHS: ${{ github.workspace }}/.internal/ansible runs-on: ubuntu-latest steps: @@ -43,7 +42,8 @@ jobs: # @v2 https://github.com/Andrew-Chen-Wang/github-wiki-action/releases/tag/v2 uses: Andrew-Chen-Wang/github-wiki-action@b386aca0ddc5ec22b6003ba4cb50fa0b17243f6c env: # this action is written such that the inputs must be specified as env vars - WIKI_DIR: ${{ env.WIKI }} + # WIKI_DIR is going to be used with rsync, it MUST end in a forward slash [/] + WIKI_DIR: ${{ env.WIKI }}/ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_MAIL: ${{ github.event.head_commit.author.email }} GH_NAME: ${{ github.event.head_commit.author.name }}[bot] From 7d4029a13fa14bc341f30aa0140fde73f8dae7c8 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 11:46:34 -0500 Subject: [PATCH 06/13] 744 --- .../internal/gha_docs/roles/generate/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml b/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml index 23bf4ea..31f07e8 100644 --- a/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml +++ b/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml @@ -7,7 +7,7 @@ ansible.builtin.file: path: '{{ output | dirname }}' state: directory - mode: '644' + mode: '744' - name: Template the workflow docs when: type == 'workflow' From 165bb8fde319736cbdf70eda21966693bc27e806 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 11:52:23 -0500 Subject: [PATCH 07/13] user woes --- .github/workflows/generate-wiki-docs.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/generate-wiki-docs.yml b/.github/workflows/generate-wiki-docs.yml index 9d65b08..2e324b8 100644 --- a/.github/workflows/generate-wiki-docs.yml +++ b/.github/workflows/generate-wiki-docs.yml @@ -46,5 +46,8 @@ jobs: WIKI_DIR: ${{ env.WIKI }}/ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_MAIL: ${{ github.event.head_commit.author.email }} - GH_NAME: ${{ github.event.head_commit.author.name }}[bot] + # GH_NAME is going to be used raw in a URL in an unquoted commandline, it can't contain spaces + # it's supposed to be a username, not a name, but it doesn't need to be a valid username, + # at least not with GITHUB_TOKEN (for a PAT, may need to match, unsure) + GH_NAME: ${{ github.event.head_commit.author.username || github.repository.owner }}[bot] WIKI_PUSH_MESSAGE: 'Docs for ${{ github.repository }}/${{ github.event.head_commit.id }} : ${{ github.event.head_commit.message }}' From 405c655b1987a779f460711dbcc5e53916f15a54 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 12:03:52 -0500 Subject: [PATCH 08/13] fork my life --- .github/workflows/generate-wiki-docs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/generate-wiki-docs.yml b/.github/workflows/generate-wiki-docs.yml index 2e324b8..2d5c49f 100644 --- a/.github/workflows/generate-wiki-docs.yml +++ b/.github/workflows/generate-wiki-docs.yml @@ -11,6 +11,10 @@ on: jobs: generate: + # if you want this workflow to run on your fork, you must: + # 1) enable the wiki (and have at minimum a main/default page) + # 2) set the GENERATE_WIKI_PAGES secret in your fork to the value "yes" + if: github.repository == 'ansible-community/github-docs-build' || secrets.GENERATE_WIKI_PAGES == 'yes' env: WIKI: ${{ github.workspace }}/wiki ANSIBLE_COLLECTIONS_PATHS: ${{ github.workspace }}/.internal/ansible From 50b3be01bb29b9d72284b59693e47c568f366983 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 12:18:59 -0500 Subject: [PATCH 09/13] crappy workaround --- .github/workflows/generate-wiki-docs.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/generate-wiki-docs.yml b/.github/workflows/generate-wiki-docs.yml index 2d5c49f..9a92114 100644 --- a/.github/workflows/generate-wiki-docs.yml +++ b/.github/workflows/generate-wiki-docs.yml @@ -9,33 +9,40 @@ on: - .internal/ansible/** - actions/**/action.yml +env: + # if you want this workflow to run on your fork, you must: + # 1) enable the wiki (and have at minimum a main/default page) + # 2) set the GENERATE_WIKI_PAGES secret in your fork to the value "yes" + SHOULD_RUN: github.repository == 'ansible-community/github-docs-build' || secrets.GENERATE_WIKI_PAGES == 'yes' + jobs: generate: - # if you want this workflow to run on your fork, you must: - # 1) enable the wiki (and have at minimum a main/default page) - # 2) set the GENERATE_WIKI_PAGES secret in your fork to the value "yes" - if: github.repository == 'ansible-community/github-docs-build' || secrets.GENERATE_WIKI_PAGES == 'yes' env: WIKI: ${{ github.workspace }}/wiki ANSIBLE_COLLECTIONS_PATHS: ${{ github.workspace }}/.internal/ansible runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - if: fromJSON(env.SHOULD_RUN) + uses: actions/checkout@v2 - name: Checkout wiki + if: fromJSON(env.SHOULD_RUN) uses: actions/checkout@v2 with: repository: ${{ github.repository }}.wiki path: ${{ env.WIKI }} - uses: actions/setup-python@v2 + if: fromJSON(env.SHOULD_RUN) with: python-version: '3.9' - name: Install Ansible + if: fromJSON(env.SHOULD_RUN) run: pip install 'ansible-core>=2.12,<2.13' --disable-pip-version-check - name: Generate new docs + if: fromJSON(env.SHOULD_RUN) run: >- ansible-playbook internal.gha_docs.generate_docs @@ -43,6 +50,7 @@ jobs: -e "workflow_output_dir=$WIKI/workflows" - name: Publish docs + if: fromJSON(env.SHOULD_RUN) # @v2 https://github.com/Andrew-Chen-Wang/github-wiki-action/releases/tag/v2 uses: Andrew-Chen-Wang/github-wiki-action@b386aca0ddc5ec22b6003ba4cb50fa0b17243f6c env: # this action is written such that the inputs must be specified as env vars From 43e592c2bda5aada131d53bf1fe4bfdcac292a35 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 12:20:38 -0500 Subject: [PATCH 10/13] change order? --- .github/workflows/generate-wiki-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate-wiki-docs.yml b/.github/workflows/generate-wiki-docs.yml index 9a92114..987b40e 100644 --- a/.github/workflows/generate-wiki-docs.yml +++ b/.github/workflows/generate-wiki-docs.yml @@ -13,7 +13,7 @@ env: # if you want this workflow to run on your fork, you must: # 1) enable the wiki (and have at minimum a main/default page) # 2) set the GENERATE_WIKI_PAGES secret in your fork to the value "yes" - SHOULD_RUN: github.repository == 'ansible-community/github-docs-build' || secrets.GENERATE_WIKI_PAGES == 'yes' + SHOULD_RUN: secrets.GENERATE_WIKI_PAGES == 'yes' || github.repository == 'ansible-community/github-docs-build' jobs: generate: From acaa6e95c38c61174f32dc3b459324af55c67e26 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 12:21:53 -0500 Subject: [PATCH 11/13] forgot to template --- .github/workflows/generate-wiki-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate-wiki-docs.yml b/.github/workflows/generate-wiki-docs.yml index 987b40e..3971590 100644 --- a/.github/workflows/generate-wiki-docs.yml +++ b/.github/workflows/generate-wiki-docs.yml @@ -13,7 +13,7 @@ env: # if you want this workflow to run on your fork, you must: # 1) enable the wiki (and have at minimum a main/default page) # 2) set the GENERATE_WIKI_PAGES secret in your fork to the value "yes" - SHOULD_RUN: secrets.GENERATE_WIKI_PAGES == 'yes' || github.repository == 'ansible-community/github-docs-build' + SHOULD_RUN: ${{ secrets.GENERATE_WIKI_PAGES == 'yes' || github.repository == 'ansible-community/github-docs-build' }} jobs: generate: From d0bb239f6060bf81b13c65e6f6b3b8dd0c52beab Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 12:43:16 -0500 Subject: [PATCH 12/13] remove branch --- .github/workflows/generate-wiki-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate-wiki-docs.yml b/.github/workflows/generate-wiki-docs.yml index 3971590..36a46fb 100644 --- a/.github/workflows/generate-wiki-docs.yml +++ b/.github/workflows/generate-wiki-docs.yml @@ -2,7 +2,7 @@ name: Generate Wiki Docs on: push: - branches: [main, 'content-docs/generate-fixups'] + branches: [main] paths: - .github/workflows/_shared* - .github/workflows/generate-wiki-docs.yml From 2bd6affd1b968534b03777b4bc39f2c30a9af302 Mon Sep 17 00:00:00 2001 From: Brian Scholer <1260690+briantist@users.noreply.github.com> Date: Mon, 17 Jan 2022 13:12:17 -0500 Subject: [PATCH 13/13] Update .internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml Co-authored-by: Felix Fontein --- .../internal/gha_docs/roles/generate/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml b/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml index 31f07e8..23f3f2d 100644 --- a/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml +++ b/.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml @@ -7,7 +7,7 @@ ansible.builtin.file: path: '{{ output | dirname }}' state: directory - mode: '744' + mode: '755' - name: Template the workflow docs when: type == 'workflow'