Merge pull request #886 from Cofinity-X/chore/TRX-30-sync-upstream #340
This file contains 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: Lint and Publish documentation | |
on: | |
workflow_dispatch: # Trigger manually | |
pull_request: | |
paths: | |
- 'docs/**' | |
push: | |
branches: | |
- main | |
paths: | |
- 'docs/**' | |
jobs: | |
lint-and-publish: | |
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions | |
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Graphviz | |
uses: ts-graphviz/setup-graphviz@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache maven packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
- name: Build with Maven | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
run: | | |
mvn -f docs/pom.xml --batch-mode generate-resources | |
- name: Install Asciidoctor Reducer | |
run: | | |
sudo gem install asciidoctor-reducer | |
- name: Reduce docs | |
run: | | |
echo $LANG | |
locale | |
asciidoctor-reducer -o docs/target/adminguide.adoc docs/src/docs/administration/administration-guide.adoc | |
asciidoctor-reducer -o docs/target/arc42.adoc docs/src/docs/arc42/full.adoc | |
- name: Cache plantuml jar | |
uses: actions/cache@v4 | |
with: | |
path: plantuml.jar | |
key: ${{ runner.os }}-file-${{ hashFiles('plantuml.jar') }} | |
- name: Download PlantUML jar | |
run: | | |
wget -O plantuml.jar https://sourceforge.net/projects/plantuml/files/plantuml.jar/download | |
- name: Place PlantUML jar in specific path | |
run: | | |
mv plantuml.jar docs/src/diagram-replacer/ | |
- name: Extract PNG-Images with PlantUML and replace PlantUML Code inside docs with PNG-Images | |
working-directory: docs/src/diagram-replacer/ | |
run: | | |
node extract.js | |
node replace.js | |
- name: Convert to Markdown | |
# currently only specified for adminguide + arc42 | |
run: | | |
npx downdoc -o docs/target/generated-docs/adminguide.md docs/src/diagram-replacer/generated-adocs/adminguide.adoc | |
npx downdoc -o docs/target/generated-docs/arc42.md docs/src/diagram-replacer/generated-adocs/arc42.adoc | |
- name: MD files post-processing | |
working-directory: docs/src/post-processing/ | |
run: | | |
export REPO=${GITHUB_REPOSITORY#*/} | |
node fix_headers.js | |
node fix_no_emphasis.js | |
node fix_https_links.js | |
node fix_relative_links.js https://$GITHUB_REPOSITORY_OWNER.github.io/$REPO/docs | |
- name: MD linting | |
run: | | |
npm install markdownlint-cli2 | |
npx markdownlint-cli2 --config docs/.markdownlint.yaml docs/target/generated-docs/adminguide.md | |
npx markdownlint-cli2 --config docs/.markdownlint.yaml docs/target/generated-docs/arc42.md | |
- name: Move assets to target directory | |
run: | | |
mv docs/src/diagram-replacer/assets/ docs/target/generated-docs/assets/ | |
- name: Generate Swagger UI | |
uses: Legion2/swagger-ui-action@v1 | |
with: | |
output: swagger-ui | |
spec-file: docs/src/api/irs-api.yaml | |
- name: Update documentation on GitHub Pages | |
if: github.ref == 'refs/heads/main' | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: "./docs/target/generated-docs" | |
destination_dir: "docs" | |
- name: Deploy Swagger UI to GitHub Pages | |
if: github.ref == 'refs/heads/main' | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: "swagger-ui" | |
destination_dir: "docs/swagger-ui" | |