@@ -3,6 +3,7 @@ name: Deploy Versioned Javadoc (Manual Trigger)
33# Select the target TAG where to run the workflow from.
44# This TAG name becomes the subdirectory under branch gh-pages/docs/${TAG}
55# where the javadocs will be copied to.
6+ # The gh-pages/docs branch/folder must exist.
67
78on :
89 workflow_dispatch :
@@ -33,12 +34,14 @@ jobs:
3334 cache : ' maven'
3435
3536 - name : Build and Generate Javadoc # POM is configured to output to target/site/apidocs
36- run : mvn javadoc:javadoc
37+ run : mvn clean javadoc:javadoc
3738
3839 - name : Deploy Javadoc via Worktree
3940 env :
4041 TAG_NAME : ${{ github.event.inputs.tag_ref }}
4142 run : |
43+ if [ -z "$TAG_NAME" ]; then echo "ERROR: No tag specified"; exit 1; fi
44+
4245 # 1. Initialize error tracking
4346 EXIT_CODE=0
4447
@@ -47,36 +50,49 @@ jobs:
4750 git config user.name "github-actions[bot]"
4851
4952 # 3. Ensure gh-pages exists and is fetched
50- git fetch origin gh-pages --depth=1 || git branch gh-pages
53+ echo "ECHO: git fetch origin gh-pages"
54+ git fetch origin gh-pages
5155
5256 # 4. Create worktree for the gh-pages branch in a separate folder
53- git worktree add ./gh-pages-dir origin/gh-pages
57+ echo "ECHO: git worktree add -B gh-pages ./gh-pages-dir origin/gh-pages"
58+ git worktree add -B gh-pages ./gh-pages-dir origin/gh-pages
5459
5560 # 5. Deployment Logic in a subshell to capture exit code
5661 (
57- set -e # Exit subshell on any internal error
58- TARGET_PATH="gh-pages-dir/docs/$TAG_NAME" # target directory inside the worktree
62+ set -e
63+ TARGET_PATH="gh-pages-dir/docs/$TAG_NAME"
5964 mkdir -p "$TARGET_PATH"
60- cp -a target/site/apidocs/. "$TARGET_PATH/"
6165
66+ echo "ECHO: cp -a target/site/apidocs/. $TARGET_PATH/"
67+ cp -a target/site/apidocs/. "$TARGET_PATH/"
6268 cd gh-pages-dir
63- git add .
69+
70+ echo "ECHO: git pull origin gh-pages --rebase"
71+ git pull origin gh-pages --rebase
72+
73+ echo "git add docs/$TAG_NAME"
74+ git add "docs/$TAG_NAME"
6475
6576 if git diff --staged --quiet; then
6677 echo "No changes detected for Javadoc $TAG_NAME."
6778 else
79+ echo "ECHO: Changes detected for Javadoc $TAG_NAME."
80+ echo "ECHO: git commit ..."
6881 git commit -m "Manual Javadoc deployment for tag $TAG_NAME"
82+ echo "ECHO: git push origin gh-pages"
6983 git push origin gh-pages
7084 fi
7185 ) || EXIT_CODE=$?
7286
7387 # 6. Cleanup (Always runs)
74- echo "Cleaning up worktree..."
88+ echo "ECHO: Cleaning up worktree..."
7589 git worktree remove --force ./gh-pages-dir || true
7690
7791 # 7. Final exit based on subshell success
7892 exit $EXIT_CODE
7993
8094 - name : Confirm Deployment
8195 if : success()
82- run : echo "Javadoc for ${{ github.event.inputs.tag_ref }} is now live on gh-pages."
96+ run : |
97+ echo "ECHO: Javadoc for ${{ github.event.inputs.tag_ref }} is now live on gh-pages."
98+
0 commit comments