Skip to content

Commit 4b70de5

Browse files
committed
chore: rework gh-pages generation
Signed-off-by: BRIAN GLEESON <Brian.Gleeson@ie.ibm.com>
1 parent f263935 commit 4b70de5

2 files changed

Lines changed: 36 additions & 13 deletions

File tree

.github/workflows/publish.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,21 @@ jobs:
3535
pages: write
3636

3737
steps:
38-
- name: Checkout code
38+
- name: Checkout main branch
3939
uses: actions/checkout@v4
4040
with:
41+
path: main
4142
persist-credentials: true
4243
fetch-depth: 0
4344

45+
- name: Checkout gh-pages branch
46+
uses: actions/checkout@v4
47+
with:
48+
fetch-depth: 0
49+
path: gh-pages
50+
persist-credentials: true
51+
ref: gh-pages
52+
4453
- name: Set up Java 11
4554
uses: actions/setup-java@v4
4655
with:

build/publishJavadoc-gha.sh

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,42 @@ set -e
66
# GITHUB_REPO_SLUG
77
# GITHUB_TAG
88

9+
printf "\n>>>>> [DEBUG] current dir...\n"
10+
pwd
11+
ls -la
12+
printf "\n>>>>> [/DEBUG] current dir...\n"
13+
914
printf "\n>>>>> Publishing javadoc for release build: repo=%s tag=%s\n" ${GITHUB_REPO_SLUG} ${GITHUB_TAG}
1015

11-
printf "\n>>>>> Checking out gh-pages branch...\n"
12-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
13-
git config --global user.name "github-actions[bot]"
14-
# Checkout the gh-pages branch as a fresh copy of latest in main
15-
git checkout -b gh-pages --no-guess
16-
git status
17-
printf "\n>>>>> Finished checking out...\n"
16+
# printf "\n>>>>> Checking out gh-pages branch...\n"
17+
# git config --global user.email "github-actions[bot]@users.noreply.github.com"
18+
# git config --global user.name "github-actions[bot]"
19+
# # Checkout the gh-pages branch as a fresh copy of latest in main
20+
# git checkout -b gh-pages --no-guess
21+
# git status
22+
# printf "\n>>>>> Finished checking out...\n"
23+
24+
# Open the "main" dir, containing the checked out main branch
25+
pushd main
1826

1927
printf "\n>>>>> Generating Javadoc...\n"
2028
mvn -B versions:set -DnewVersion="${GITHUB_TAG}" -DgenerateBackupPoms=false
2129
mvn clean javadoc:aggregate --settings build/.github.settings.xml
2230
printf "\n>>>>> Finished generating Javadoc...\n"
2331

24-
printf "\n>>>>> [DEBUG] current dir contents...\n"
32+
printf "\n>>>>> [DEBUG] ls -la...\n"
2533
ls -la
26-
printf "\n>>>>> [/DEBUG] current dir contents...\n"
34+
printf "\n>>>>> [/DEBUG] ls -la...\n"
2735

2836
# Create a new directory for this branch/tag and copy the javadocs there.
2937
printf "\n>>>>> Copying javadocs to new directory: docs/%s\n" ${GITHUB_TAG}
30-
rm -rf docs/${GITHUB_TAG}
31-
mkdir -p docs/${GITHUB_TAG}
32-
cp -rf target/site/apidocs/* docs/${GITHUB_TAG}
38+
rm -rf ../gh-pages/docs/${GITHUB_TAG}
39+
mkdir -p ../gh-pages/docs/${GITHUB_TAG}
40+
cp -rf target/site/apidocs/* ../gh-pages/docs/${GITHUB_TAG}
41+
42+
# Return to root dir, then open "gh-pages" dir
43+
popd
44+
pushd gh-pages
3345

3446
printf "\n>>>>> Generating gh-pages index.html...\n"
3547
build/generateJavadocIndex.sh > index.html
@@ -42,4 +54,6 @@ printf "\n>>>>> Committed changes...\n"
4254
git push -f origin gh-pages
4355
printf "\n>>>>> Pushed changes...\n"
4456

57+
popd
58+
4559
printf "\n>>>>> Published javadoc for release build: repo=%s tag=%s\n" ${GITHUB_REPO_SLUG} ${GITHUB_TAG}

0 commit comments

Comments
 (0)