Build Documentation #301
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: Build Documentation | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 0 * * 0' # every Sunday at 00:00 | |
workflow_dispatch: | |
inputs: | |
distinct_id: | |
# Used by codex-/return-dispatch action from another workflow to keep track of the run. Manual runs using the UI do not require this input. | |
description: 'The distinct id of the workflow run (optional)' | |
log_level: | |
description: 'Log level for the Antora build (debug, info, warn, error)' | |
failure_level: | |
description: 'Log failure level for the Antora build (fatal, error, warn, none)' | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
env: | |
MAVEN_CLI_OPTS: '--batch-mode --errors --fail-at-end -T 1C' | |
# Define color variables | |
RED: '\033[0;31m' | |
GREEN: '\033[0;32m' | |
NC: '\033[0m' # No Color | |
steps: | |
- name: Get distinct ID ${{ github.event.inputs.distinct_id }} | |
run: echo ${{ github.event.inputs.distinct_id }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Checkout isyfact-standards (master) | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isyfact-standards | |
ref: master | |
lfs: true | |
sparse-checkout: isyfact-standards-doc/src/docs/antora | |
path: isyfact-standards | |
- name: Checkout isyfact-standards (release/3.2.0) | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isyfact-standards | |
ref: 3.2.0 | |
lfs: true | |
sparse-checkout: isyfact-standards-doc/src/docs/antora | |
path: isyfact-standards-3.2.0 | |
- name: Checkout isyfact-standards (3.3.x) | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isyfact-standards | |
ref: release/3.x | |
lfs: true | |
sparse-checkout: isyfact-standards-doc/src/docs/antora | |
path: isyfact-standards-3.3.x | |
- name: Checkout isy-documentation | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isy-documentation | |
ref: master | |
lfs: true | |
path: isy-documentation | |
- name: Checkout isy-web | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isy-web | |
ref: master | |
lfs: true | |
sparse-checkout: isy-web-doc/src/docs/antora | |
path: isy-web | |
- name: Checkout isy-angular-widgets | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isy-angular-widgets | |
ref: main | |
lfs: true | |
sparse-checkout: isy-angular-widgets-doc | |
path: isy-angular-widgets | |
- name: Fetch latest tags | |
id: fetch-latest-tags | |
run: | | |
repos=("isy-datetime" "isy-datetime-persistence" "isy-polling" "isy-sonderzeichen" "isy-security" "isy-task" "isy-util") | |
for repo in "${repos[@]}"; do | |
latest_tag=$(git ls-remote --tags https://github.com/IsyFact/$repo.git | grep -o 'refs/tags/[0-9]*\.[0-9]*\.[0-9]*$' | sort -V | tail -n1 | awk -F'/' '{print $3}') | |
if [ -z "$latest_tag" ]; then | |
latest_tag="develop" | |
fi | |
echo "$repo=$latest_tag" >> $GITHUB_OUTPUT | |
done | |
- name: Checkout isy-datetime | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isy-datetime | |
ref: ${{ steps.fetch-latest-tags.outputs.isy-datetime }} | |
lfs: true | |
sparse-checkout: docs | |
path: isy-datetime | |
- name: Checkout isy-datetime-persistence | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isy-datetime-persistence | |
ref: ${{ steps.fetch-latest-tags.outputs.isy-datetime-persistence }} | |
lfs: true | |
sparse-checkout: docs | |
path: isy-datetime-persistence | |
- name: Checkout isy-polling | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isy-polling | |
ref: ${{ steps.fetch-latest-tags.outputs.isy-polling }} | |
lfs: true | |
sparse-checkout: docs | |
path: isy-polling | |
- name: Checkout isy-sonderzeichen | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isy-sonderzeichen | |
ref: ${{ steps.fetch-latest-tags.outputs.isy-sonderzeichen }} | |
lfs: true | |
sparse-checkout: docs | |
path: isy-sonderzeichen | |
- name: Checkout isy-security | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isy-security | |
ref: ${{ steps.fetch-latest-tags.outputs.isy-security }} | |
lfs: true | |
sparse-checkout: docs | |
path: isy-security | |
- name: Checkout isy-task | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isy-task | |
ref: ${{ steps.fetch-latest-tags.outputs.isy-task }} | |
lfs: true | |
sparse-checkout: docs | |
path: isy-task | |
- name: Checkout isy-util | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isy-util | |
ref: ${{ steps.fetch-latest-tags.outputs.isy-util }} | |
lfs: true | |
sparse-checkout: docs | |
path: isy-util | |
- name: Checkout isy-bedienkonzept | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isy-bedienkonzept | |
ref: main | |
lfs: true | |
sparse-checkout: isy-bedienkonzept-doc | |
path: isy-bedienkonzept | |
- name: Checkout isyfact-standards-referenzimplementierung | |
uses: actions/checkout@v4 | |
with: | |
repository: IsyFact/isyfact-standards-referenzimplementierung | |
ref: main | |
lfs: true | |
sparse-checkout: isyfact-standards-referenzimplementierung-doc | |
path: isyfact-standards-referenzimplementierung | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: temurin | |
cache: maven | |
- name: Generate Templates (master) | |
run: mvn $MAVEN_CLI_OPTS -f ./isyfact-standards/isyfact-standards-doc package | |
- name: Generate Templates (release/3.2.0) | |
run: mvn $MAVEN_CLI_OPTS -f ./isyfact-standards-3.2.0/isyfact-standards-doc package | |
- name: Generate Templates (release/3.3.x) | |
run: mvn $MAVEN_CLI_OPTS -f ./isyfact-standards-3.3.x/isyfact-standards-doc package | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: npm | |
# @setup-node does not provide node_modules in cache | |
- name: Cache node modules | |
uses: actions/cache@v4 | |
with: | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: ${{ runner.os }}-npm- | |
path: | | |
**/node_modules | |
- name: Install Dependencies | |
run: npm ci | |
- name: Build Documentation | |
run: | | |
# Run Antora with JSON logging, pipe output to process-logs.sh | |
chmod +x process-logs.sh | |
npx antora \ | |
--log-format=json \ | |
--log-level=${{ github.event.inputs.log_level || 'info' }} \ | |
--log-failure-level=${{ github.event.inputs.failure_level || 'fatal' }} \ | |
antora-playbook.yml > antora_output.log || BUILD_FAILED=true | |
# Pipe the output to process-logs.sh | |
echo "Processing JSON logs..." | |
# Capture the output of the log processing into a variable | |
PROCESSED_LOGS=$(cat antora_output.log | bash process-logs.sh) | |
# If the build failed and process-logs.sh produces no output, fallback to default logs | |
if [ "$BUILD_FAILED" = true ] && [ -z "$PROCESSED_LOGS" ]; then | |
echo "Displaying default logs:" | |
cat antora_output.log | |
echo -e "${RED}Antora documentation build failed.${NC}" | |
exit 1 | |
elif [ "$BUILD_FAILED" = true ]; then | |
echo "$PROCESSED_LOGS" | |
echo -e "${RED}Antora documentation build failed.${NC}" | |
exit 1 | |
else | |
echo "$PROCESSED_LOGS" | |
echo -e "${GREEN}Antora documentation build completed successfully.${NC}" | |
fi | |
- name: Upload docs folder as pages artifact for GitHub Pages | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: docs | |
- name: Upload docs folder as artifact for Link Checker | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docs | |
path: docs | |
Deploy: | |
runs-on: ubuntu-latest | |
needs: [Build] | |
concurrency: | |
group: gh-pages | |
cancel-in-progress: false | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Setup GitHub Pages | |
uses: actions/configure-pages@v4 | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |