Skip to content

Commit 3b383c7

Browse files
wiki docs generation - fixups and fork ops (#22)
* create dir * test workflow * dirname * add path to trigger * move trailing slash * 744 * user woes * fork my life * crappy workaround * change order? * forgot to template * remove branch * Update .internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
1 parent 16c96f2 commit 3b383c7

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

.github/workflows/generate-wiki-docs.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,60 @@ on:
66
paths:
77
- .github/workflows/_shared*
88
- .github/workflows/generate-wiki-docs.yml
9+
- .internal/ansible/**
910
- actions/**/action.yml
1011

12+
env:
13+
# if you want this workflow to run on your fork, you must:
14+
# 1) enable the wiki (and have at minimum a main/default page)
15+
# 2) set the GENERATE_WIKI_PAGES secret in your fork to the value "yes"
16+
SHOULD_RUN: ${{ secrets.GENERATE_WIKI_PAGES == 'yes' || github.repository == 'ansible-community/github-docs-build' }}
17+
1118
jobs:
1219
generate:
1320
env:
14-
# this path is going to be used with rsync, it MUST end in a forward slash [/]
15-
WIKI: ${{ github.workspace }}/wiki/
21+
WIKI: ${{ github.workspace }}/wiki
1622
ANSIBLE_COLLECTIONS_PATHS: ${{ github.workspace }}/.internal/ansible
1723
runs-on: ubuntu-latest
1824
steps:
19-
- uses: actions/checkout@v2
25+
- if: fromJSON(env.SHOULD_RUN)
26+
uses: actions/checkout@v2
2027

2128
- name: Checkout wiki
29+
if: fromJSON(env.SHOULD_RUN)
2230
uses: actions/checkout@v2
2331
with:
2432
repository: ${{ github.repository }}.wiki
2533
path: ${{ env.WIKI }}
2634

2735
- uses: actions/setup-python@v2
36+
if: fromJSON(env.SHOULD_RUN)
2837
with:
2938
python-version: '3.9'
3039

3140
- name: Install Ansible
41+
if: fromJSON(env.SHOULD_RUN)
3242
run: pip install 'ansible-core>=2.12,<2.13' --disable-pip-version-check
3343

3444
- name: Generate new docs
45+
if: fromJSON(env.SHOULD_RUN)
3546
run: >-
3647
ansible-playbook
3748
internal.gha_docs.generate_docs
3849
-e "action_output_dir=$WIKI/actions"
3950
-e "workflow_output_dir=$WIKI/workflows"
4051
4152
- name: Publish docs
53+
if: fromJSON(env.SHOULD_RUN)
4254
# @v2 https://github.com/Andrew-Chen-Wang/github-wiki-action/releases/tag/v2
4355
uses: Andrew-Chen-Wang/github-wiki-action@b386aca0ddc5ec22b6003ba4cb50fa0b17243f6c
4456
env: # this action is written such that the inputs must be specified as env vars
45-
WIKI_DIR: ${{ env.WIKI }}
57+
# WIKI_DIR is going to be used with rsync, it MUST end in a forward slash [/]
58+
WIKI_DIR: ${{ env.WIKI }}/
4659
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4760
GH_MAIL: ${{ github.event.head_commit.author.email }}
48-
GH_NAME: ${{ github.event.head_commit.author.name }}[bot]
61+
# GH_NAME is going to be used raw in a URL in an unquoted commandline, it can't contain spaces
62+
# it's supposed to be a username, not a name, but it doesn't need to be a valid username,
63+
# at least not with GITHUB_TOKEN (for a PAT, may need to match, unsure)
64+
GH_NAME: ${{ github.event.head_commit.author.username || github.repository.owner }}[bot]
4965
WIKI_PUSH_MESSAGE: 'Docs for ${{ github.repository }}/${{ github.event.head_commit.id }} : ${{ github.event.head_commit.message }}'

.internal/ansible/ansible_collections/internal/gha_docs/roles/generate/tasks/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
set_fact:
44
_src: "{{ lookup('ansible.builtin.file', file) | from_yaml }}"
55

6+
- name: Ensure output dir exists
7+
ansible.builtin.file:
8+
path: '{{ output | dirname }}'
9+
state: directory
10+
mode: '755'
11+
612
- name: Template the workflow docs
713
when: type == 'workflow'
814
vars:

0 commit comments

Comments
 (0)