@@ -34,12 +34,14 @@ jobs:
3434 cache : ' maven'
3535
3636 - name : Build and Generate Javadoc # POM is configured to output to target/site/apidocs
37- run : mvn javadoc:javadoc
37+ run : mvn clean javadoc:javadoc
3838
3939 - name : Deploy Javadoc via Worktree
4040 env :
4141 TAG_NAME : ${{ github.event.inputs.tag_ref }}
4242 run : |
43+ if [ -z "$TAG_NAME" ]; then echo "ERROR: No tag specified"; exit 1; fi
44+
4345 # 1. Initialize error tracking
4446 EXIT_CODE=0
4547
@@ -48,42 +50,48 @@ jobs:
4850 git config user.name "github-actions[bot]"
4951
5052 # 3. Ensure gh-pages exists and is fetched
51- echo "git fetch origin gh-pages"
53+ echo "ECHO: git fetch origin gh-pages"
5254 git fetch origin gh-pages
5355
5456 # 4. Create worktree for the gh-pages branch in a separate folder
55- echo "git worktree add ./gh-pages-dir origin/gh-pages"
56- 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
5759
5860 # 5. Deployment Logic in a subshell to capture exit code
5961 (
6062 set -e
6163 TARGET_PATH="gh-pages-dir/docs/$TAG_NAME"
6264 mkdir -p "$TARGET_PATH"
63- echo "cp -a target/site/apidocs/. $TARGET_PATH/"
65+
66+ echo "ECHO: cp -a target/site/apidocs/. $TARGET_PATH/"
6467 cp -a target/site/apidocs/. "$TARGET_PATH/"
6568 cd gh-pages-dir
69+
70+ echo "ECHO: git pull origin gh-pages --rebase"
71+ git pull origin gh-pages --rebase
72+
6673 echo "git add docs/$TAG_NAME"
6774 git add "docs/$TAG_NAME"
6875
6976 if git diff --staged --quiet; then
7077 echo "No changes detected for Javadoc $TAG_NAME."
7178 else
72- echo "Changes detected for Javadoc $TAG_NAME."
73- echo "git commit ..."
79+ echo "ECHO: Changes detected for Javadoc $TAG_NAME."
80+ echo "ECHO: git commit ..."
7481 git commit -m "Manual Javadoc deployment for tag $TAG_NAME"
75- echo "git push origin gh-pages"
82+ echo "ECHO: git push origin gh-pages"
7683 git push origin gh-pages
7784 fi
7885 ) || EXIT_CODE=$?
7986
8087 # 6. Cleanup (Always runs)
81- echo "Cleaning up worktree..."
88+ echo "ECHO: Cleaning up worktree..."
8289 git worktree remove --force ./gh-pages-dir || true
8390
8491 # 7. Final exit based on subshell success
8592 exit $EXIT_CODE
8693
8794 - name : Confirm Deployment
8895 if : success()
89- run : echo "Javadoc for ${{ github.event.inputs.tag_ref }} is now live on gh-pages."
96+ run : echo "ECHO: Javadoc for ${{ github.event.inputs.tag_ref }} is now live on gh-pages."
97+
0 commit comments