Build Docs #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Docs | |
| on: | |
| push: | |
| paths: | |
| - README-source.adoc | |
| - docs/CONTRIBUTING-source.adoc | |
| - AGENTS-source.adoc | |
| - docs/attributes.adoc | |
| - docs/gesinn-it-docs-master-pub | |
| - docs/gesinn-it-docs-master-pub/** | |
| branches: | |
| - '**' | |
| workflow_dispatch: | |
| concurrency: | |
| group: adoc-build-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: 'true' | |
| - name: Install tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y asciidoctor pandoc python3-yaml | |
| sudo gem install asciidoctor-reducer --pre | |
| # --- README --- | |
| - name: Reduce README | |
| run: asciidoctor-reducer -o README.adoc README-source.adoc | |
| - name: Add autogenerated header (README) | |
| run: | | |
| printf "// THIS FILE IS AUTO-GENERATED.\n// Edit README-source.adoc instead.\n\n" | cat - README.adoc > README.tmp | |
| mv README.tmp README.adoc | |
| # --- CONTRIBUTING --- | |
| - name: Reduce CONTRIBUTING | |
| run: asciidoctor-reducer -o docs/CONTRIBUTING.adoc docs/CONTRIBUTING-source.adoc | |
| - name: Add autogenerated header (CONTRIBUTING) | |
| run: | | |
| printf "// THIS FILE IS AUTO-GENERATED.\n// Edit docs/CONTRIBUTING-source.adoc instead.\n\n" | cat - docs/CONTRIBUTING.adoc > docs/CONTRIBUTING.tmp | |
| mv docs/CONTRIBUTING.tmp docs/CONTRIBUTING.adoc | |
| # --- AGENTS --- | |
| - name: Reduce AGENTS source (flatten includes) | |
| run: | | |
| asciidoctor-reducer \ | |
| -o AGENTS.adoc \ | |
| AGENTS-source.adoc | |
| - name: Convert AsciiDoc to DocBook | |
| run: | | |
| asciidoctor \ | |
| -b docbook5 \ | |
| -o AGENTS.xml \ | |
| AGENTS.adoc | |
| - name: Convert DocBook to Markdown | |
| run: | | |
| pandoc \ | |
| -f docbook \ | |
| -t gfm \ | |
| AGENTS.xml \ | |
| -o AGENTS.md | |
| - name: Add autogenerated header (AGENTS) | |
| run: | | |
| printf "<!-- THIS FILE IS AUTO-GENERATED. Edit AGENTS-source.adoc instead. -->\n\n" | \ | |
| cat - AGENTS.md > tmp | |
| mv tmp AGENTS.md | |
| - name: Remove intermediate files | |
| run: | | |
| rm -f \ | |
| AGENTS.adoc \ | |
| AGENTS.xml | |
| # --- Instructions --- | |
| - name: Create output directories | |
| run: | | |
| mkdir -p .claude | |
| mkdir -p .github/instructions | |
| mkdir -p src libs tests .github | |
| - name: Create CLAUDE.md from AGENTS.md | |
| run: cp AGENTS.md .claude/CLAUDE.md | |
| - name: Build instructions (scope loop) | |
| shell: bash | |
| run: | | |
| BASE="docs/gesinn-it-docs-master-pub/documents/mediawiki/instructions" | |
| declare -A APPLY_TO=( | |
| [php]="**/*.php" | |
| [js]="**/*.{js,css,less}" | |
| [testing]="tests/**" | |
| [ci]=".github/**,Makefile,build/**" | |
| ) | |
| declare -A SUBTREE_DIR=( | |
| [php]="src" | |
| [js]="libs" | |
| [testing]="tests" | |
| [ci]=".github" | |
| ) | |
| for SCOPE in php js testing ci; do | |
| APPLYTO="${APPLY_TO[$SCOPE]}" | |
| DIR="${SUBTREE_DIR[$SCOPE]}" | |
| asciidoctor-reducer \ | |
| -a phan \ | |
| -o /tmp/${SCOPE}.adoc \ | |
| ${BASE}/${SCOPE}.adoc | |
| asciidoctor \ | |
| -b docbook5 \ | |
| -o /tmp/${SCOPE}.xml \ | |
| /tmp/${SCOPE}.adoc | |
| pandoc \ | |
| -f docbook \ | |
| -t gfm \ | |
| /tmp/${SCOPE}.xml \ | |
| -o /tmp/${SCOPE}.md | |
| printf '%s\n%s\n%s\n%s\n\n' \ | |
| '---' \ | |
| "applyTo: \"${APPLYTO}\"" \ | |
| '---' \ | |
| "<!-- AUTO-GENERATED from docs/gesinn-it-docs-master-pub/documents/mediawiki/instructions/${SCOPE}.adoc -->" \ | |
| | cat - /tmp/${SCOPE}.md \ | |
| > .github/instructions/${SCOPE}.instructions.md | |
| printf '%s\n\n' \ | |
| "<!-- AUTO-GENERATED from docs/gesinn-it-docs-master-pub/documents/mediawiki/instructions/${SCOPE}.adoc -->" \ | |
| | cat - /tmp/${SCOPE}.md \ | |
| > ${DIR}/AGENTS.md | |
| done | |
| # --- Skills --- | |
| - name: Build skills | |
| run: | | |
| PROJECT_TYPE=$(grep ':project_type:' docs/attributes.adoc | sed 's/.*: *//') | |
| python3 docs/gesinn-it-docs-master-pub/scripts/build-skills.py \ | |
| --manifests-dir docs/gesinn-it-docs-master-pub/skills/manifests \ | |
| --snippets-dir docs/gesinn-it-docs-master-pub/snippets \ | |
| --claude-skills-dir .claude/skills \ | |
| --agents-skills-dir .agents/skills \ | |
| --scope "$PROJECT_TYPE" | |
| # --- Commit all generated files --- | |
| - name: Commit generated files | |
| uses: EndBug/add-and-commit@v10 | |
| with: | |
| add: | | |
| README.adoc | |
| docs/CONTRIBUTING.adoc | |
| AGENTS.md | |
| .claude/CLAUDE.md | |
| .github/instructions/ | |
| .github/AGENTS.md | |
| src/AGENTS.md | |
| libs/AGENTS.md | |
| tests/AGENTS.md | |
| .claude/skills/ | |
| .agents/skills/ | |
| pull: '--rebase --autostash' | |
| message: "docs(ci): update generated documentation [skip ci]" |