Skip to content

Generate Docs

Generate Docs #551

Workflow file for this run

name: Generate Docs
# Triggers:
# - When the "CI Build" workflow completes (regardless of success/failure),
# but the job will check for success using an `if` condition.
# - When files in any `_ext` folder under /docs are pushed to master.
# - When manually triggered via the Actions UI.
on:
workflow_run:
workflows: ["CI Build"] # Name of the workflow to listen to
types:
- completed
push:
branches:
- master
paths:
- 'docs/**/_ext/**'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
generate-docs:
if: >
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Checkout master
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
with:
ref: master
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Java
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165
with:
distribution: 'temurin'
java-version: 17
- name: Build biz.aQute.bnd JAR
run: |
./gradlew --no-daemon -Dmaven.repo.local=dist/m2 --continue :biz.aQute.bnd:build -x test -x testOSGi
- name: Run docs generate script
working-directory: docs
run: |
chmod +x generate.sh
./generate.sh
- name: Create PR if changes exist
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
echo "== Git status =="
git status
echo "== Diff summary =="
git diff --stat || true
# Check for any tracked *or untracked* changes
if ! git diff --quiet --ignore-submodules --exit-code || [ -n "$(git ls-files --others --exclude-standard)" ]; then
branch="docs/gen-$(date +%Y-%m-%d-%H%M%S)"
git checkout -b "$branch"
git add -A
git commit -m "docs: auto-generated content"
git push origin "$branch"
gh pr create \
--title "docs: update generated docs" \
--body "This PR contains auto-generated documentation files." \
--base master \
--head "$branch"
else
echo "No generated changes to commit."
fi