diff --git a/.github/workflows/generate-wiki-docs.yml b/.github/workflows/generate-wiki-docs.yml index 57cfbf3..36a46fb 100644 --- a/.github/workflows/generate-wiki-docs.yml +++ b/.github/workflows/generate-wiki-docs.yml @@ -6,32 +6,43 @@ on: paths: - .github/workflows/_shared* - .github/workflows/generate-wiki-docs.yml + - .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: ${{ secrets.GENERATE_WIKI_PAGES == 'yes' || github.repository == 'ansible-community/github-docs-build' }} + 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: - - 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 @@ -39,11 +50,16 @@ 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 - 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] + # 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 }}' 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..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 @@ -3,6 +3,12 @@ set_fact: _src: "{{ lookup('ansible.builtin.file', file) | from_yaml }}" +- name: Ensure output dir exists + ansible.builtin.file: + path: '{{ output | dirname }}' + state: directory + mode: '755' + - name: Template the workflow docs when: type == 'workflow' vars: