Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions .github/workflows/generate-wiki-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,60 @@ 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
-e "action_output_dir=$WIKI/actions"
-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 }}'
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down