Skip to content

Commit 76fe071

Browse files
authored
ci: Gha 9747 (#1190)
* ci: fix docs * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix * ci: fix
1 parent 818ec6a commit 76fe071

File tree

1 file changed

+31
-44
lines changed

1 file changed

+31
-44
lines changed

build/publish_gha.sh

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,38 @@
22

33
# This script will publish the aggregated javadocs found in the project's "target" directory.
44
# The javadocs are committed and pushed to the git repository's gh-pages branch.
5-
# Be sure to customize this file to reflect your SDK project's settings (git url,
5+
# Be sure to customize this file to reflect your SDK project's settings
66

7-
export GHA_BRANCH=${GHA_BRANCH##*/} # Get the last part for true branch name - "refs/heads/9260_gha"
8-
# Avoid publishing javadocs for a PR build
9-
if [ "$GHA_PULL_REQUEST" == "false" ] && [ "$GHA_BRANCH" ]; then
10-
printf "\n>>>>> Publishing javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s pr=%s tag=%s commit=%s\n" ${GHA_REPO_SLUG} ${GHA_BRANCH} ${GHA_BUILD_NUMBER} ${GHA_JOB_NUMBER} ${GHA_PULL_REQUEST} ${GHA_TAG} ${GHA_COMMIT}
7+
export GHA_TAG=${GHA_TAG##*/} # Get the last part for true tag name - "refs/heads/vx.x.x"
8+
printf "\n>>>>> Publishing javadoc for release build: %s\n" ${GHA_TAG}
119

12-
printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'\n"
13-
rm -fr ./gh-pages
14-
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/watson-developer-cloud/java-sdk.git gh-pages > /dev/null
10+
printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'\n"
11+
rm -fr ./gh-pages
12+
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/watson-developer-cloud/java-sdk.git gh-pages > /dev/null
13+
printf "\n>>>>> Finished cloning...\n"
1514

16-
printf "\n>>>>> Finished cloning...\n"
17-
18-
pushd gh-pages
15+
pushd gh-pages
1916

20-
# Create a new directory for this branch/tag and copy the aggregated javadocs there.
21-
printf "\n>>>>> Copying aggregated javadocs to new tagged-release directory: %s\n" ${GHA_BRANCH}
22-
rm -rf docs/${GHA_BRANCH}
23-
mkdir -p docs/${GHA_BRANCH}
24-
cp -rf ../target/site/apidocs/* docs/${GHA_BRANCH}
25-
26-
printf "\n>>>>> Generating gh-pages index.html...\n"
27-
../build/generateJavadocIndex.sh > index.html
28-
29-
# Update the 'latest' symlink to point to this branch if it's a tagged release.
30-
if [ -n "$GHA_TAG" ]; then
31-
pushd docs
32-
rm latest
33-
ln -s ./${GHA_TAG} latest
34-
printf "\n>>>>> Updated 'docs/latest' symlink:\n"
35-
ls -l latest
36-
popd
37-
fi
38-
39-
printf "\n>>>>> Committing new javadoc...\n"
40-
git add -f .
41-
git commit -m "Javadoc for release ${GHA_TAG} (${GHA_COMMIT})"
42-
git push -f origin gh-pages
43-
44-
popd
45-
46-
printf "\n>>>>> Published javadoc for release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${GHA_REPO_SLUG} ${GHA_BRANCH} ${GHA_BUILD_NUMBER} ${GHA_JOB_NUMBER}
47-
48-
else
49-
50-
printf "\n>>>>> Javadoc publishing bypassed for non-release build: repo=%s branch=%s build_num=%s job_num=%s pr=%s tag=%s commit=%s\n" ${GHA_REPO_SLUG} ${GHA_BRANCH} ${GHA_BUILD_NUMBER} ${GHA_JOB_NUMBER} ${GHA_PULL_REQUEST} ${GHA_TAG} ${GHA_COMMIT}
51-
52-
fi
17+
# Create a new directory for this branch/tag and copy the aggregated javadocs there.
18+
printf "\n>>>>> Copying aggregated javadocs to new tagged-release directory: %s\n" ${GHA_TAG}
19+
rm -rf docs/${GHA_TAG}
20+
mkdir -p docs/${GHA_TAG}
21+
cp -rf ../target/site/apidocs/* docs/${GHA_TAG}
22+
23+
printf "\n>>>>> Generating gh-pages index.html...\n"
24+
../build/generateJavadocIndex.sh > index.html
25+
26+
# Update the 'latest' symlink to point to this branch if it's a tagged release.
27+
pushd docs
28+
rm latest
29+
ln -s ./${GHA_TAG} latest
30+
printf "\n>>>>> Updated 'docs/latest' symlink:\n"
31+
ls -l latest
32+
popd
33+
34+
printf "\n>>>>> Committing new javadoc for commit: %s\n" ${GHA_COMMIT}
35+
git add -f .
36+
git commit -m "chore: Javadoc for release ${GHA_TAG} (${GHA_COMMIT})"
37+
git push -f origin gh-pages
38+
39+
popd

0 commit comments

Comments
 (0)