Skip to content

Fix directory in gh action. #20

Fix directory in gh action.

Fix directory in gh action. #20

name: Build and Deploy Javadoc
on:
push:
branches:
- master
- texify-everything # TODO: This is temporary just for testing.
jobs:
# 1) Build the Javadoc and upload as artifact
build-docs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4.2.2
- name: Set up JDK 23
uses: actions/setup-java@v4.7.0
with:
distribution: 'zulu'
java-version: 23
- name: Build Javadoc
run: |
mvn clean install
mvn javadoc:javadoc \
-Dmaven.javadoc.failOnError=false \
-Dmaven.javadoc.skip=false
- name: Inject MathJax script
# Adjust path to where your Javadoc output is actually generated
run: |
find target/reports/apidocs -type f -name "*.html" -exec \
sed -i '/<\/head>/i <script type="text/javascript" id="MathJax-script" async \
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"> \
</script>' {} +
# - name: Convert LaTeX
# run: |
# for file in $(find target/site/apidocs -name "*.html"); do
# sed -i -E 's@<span class="latex-replaceable">.*?</span>\s*<!-- LATEX: (.*?) -->@\1@g' "$file"
# done
- name: Convert LaTeX
run: |
for file in $(find target/reports/apidocs -name "*.html"); do
awk '
BEGIN { inside_latex = 0; latex_content = "" }
/<!-- LATEX:/ { inside_latex = 1; next }
inside_latex && /\*\// { inside_latex = 0; print latex_content; latex_content=""; next }
inside_latex { gsub(/\* ?/, ""); latex_content = latex_content "\n" $0; next }
{ print }
' "$file" > tmpfile && mv tmpfile "$file"
done
- name: Upload Pages Artifact
# This action collects the directory containing docs
# and makes it available as an artifact for later jobs
uses: actions/upload-pages-artifact@v3.0.1
with:
# Path to the folder containing generated docs
# Adjust path to match your actual Javadoc output
path: target/reports/apidocs
# --- 2) Deploy the artifact to GitHub Pages
deploy-docs:
needs: build-docs
runs-on: ubuntu-latest
permissions:
pages: write # required
id-token: write # required
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4.0.5
with:
token: ${{ secrets.GITHUB_TOKEN }}