Skip to content

Commit 2602f2e

Browse files
committed
update javadoc.yml and ManualJavadocsDeploy.sh
1 parent 906fe1b commit 2602f2e

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

.github/workflows/javadoc.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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+

tools/ManualJavadocsDeploy.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ EXIT_CODE=0
1919
mkdir -p "$TARGET_PATH"
2020
cp -a target/site/apidocs/. "$TARGET_PATH/"
2121
cd gh-pages-dir
22+
2223
echo "ECHO: git pull origin gh-pages --rebase"
2324
git pull origin gh-pages --rebase
25+
2426
echo "ECHO: git add docs/$TAG_NAME"
2527
git add "docs/$TAG_NAME"
2628

@@ -41,7 +43,12 @@ EXIT_CODE=0
4143
echo "ECHO: Cleaning up worktree..."
4244
git worktree remove --force ./gh-pages-dir || true
4345

44-
# Final exit based on subshell success
45-
exit $EXIT_CODE
46-
if: success()
47-
run: echo "ECHO: Javadoc for $TAG_NAME is now live on gh-pages."
46+
# Check the exit code and report success or failure
47+
if [ $EXIT_CODE -eq 0 ]; then
48+
echo "ECHO: Javadoc for $TAG_NAME is now live on gh-pages."
49+
else
50+
echo "ECHO: Javadoc deployment failed for $TAG_NAME."
51+
fi
52+
53+
# Final exit
54+
exit $EXIT_CODE

0 commit comments

Comments
 (0)