Skip to content

Commit c7000f8

Browse files
committed
chore: fix github actions issues
Signed-off-by: BRIAN GLEESON <Brian.Gleeson@ie.ibm.com>
1 parent 492e230 commit c7000f8

4 files changed

Lines changed: 63 additions & 65 deletions

File tree

.github/workflows/publish.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
name: release
1+
name: publish
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
release:
5+
types: [created]
76
workflow_dispatch:
87
inputs:
98
publish_maven:
109
description: 'Publish to Maven'
1110
required: false
1211
type: boolean
1312
default: true
14-
inputs:
1513
publish_javadoc:
1614
description: 'Publish JavaDoc to gh-pages branch'
1715
required: false
@@ -29,10 +27,11 @@ jobs:
2927
runs-on: ubuntu-latest
3028
timeout-minutes: 30
3129
# Only publish when semantic-release creates a release commit (starts with "chore(release):")
32-
if: (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(release):')) || (github.event_name == 'workflow_dispatch' && inputs.publish_javadoc)
30+
# if: (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(release):')) || (github.event_name == 'workflow_dispatch' && inputs.publish_javadoc)
3331

3432
permissions:
3533
contents: write
34+
pages: write
3635

3736
steps:
3837
- name: Checkout code
@@ -52,9 +51,9 @@ jobs:
5251

5352
- name: Publish Javadocs
5453
env:
55-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
56-
GH_REPO_SLUG: ${{ github.repository }}
57-
GH_TAG: ${{ github.ref_name}}
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
GITHUB_REPO_SLUG: ${{ github.repository }}
56+
GITHUB_TAG: ${{ github.ref_name}}
5857
run: |
5958
mvn clean javadoc:aggregate --settings build/.github.settings.xml
6059
build/publishJavadoc-gha.sh
@@ -63,11 +62,10 @@ jobs:
6362
# Requires GPG_KEYNAME, GPG_PRIVATE_KEY, GPG_PASSPHRASE, CP_USERNAME, CP_PASSWORD
6463
# Missing: GPG_PRIVATE_KEY, GPG_PASSPHRASE, CP_PASSWORD
6564
name: Publish to Maven Central
66-
needs: semantic-release
6765
runs-on: ubuntu-latest
6866
timeout-minutes: 30
6967
# Only publish when semantic-release creates a release commit (starts with "chore(release):")
70-
if: (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(release):')) || (github.event_name == 'workflow_dispatch' && inputs.publish_maven)
68+
# if: (github.event_name == 'push' && startsWith(github.event.head_commit.message, 'chore(release):')) || (github.event_name == 'workflow_dispatch' && inputs.publish_maven)
7169

7270
steps:
7371
- name: Checkout code

build/generateJavadocIndex.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ echo '<!DOCTYPE html>
2323
2424
<p>Javadoc by release:</p>
2525
<ul>'
26-
echo ${GH_TAG} | sed 's/^.*/ <li><a href="docs\/&">Latest release<\/a><\/li>/'
26+
echo ${GITHUB_TAG} | sed 's/^.*/ <li><a href="docs\/&">Latest release<\/a><\/li>/'
2727
ls docs | grep --invert-match index.html | sed 's/^.*/ <li><a href="docs\/&">&<\/a><\/li>/'
2828
echo ' </ul>
2929
</div>

build/publishJavadoc-gha.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
#!/bin/bash
22

33
# Required environment variables:
4-
# GH_TOKEN
5-
# GH_REPO_SLUG
6-
# GH_TAG
4+
# GITHUB_TOKEN
5+
# GITHUB_REPO_SLUG
6+
# GITHUB_TAG
77

8-
printf "\n>>>>> Publishing javadoc for release build: repo=%s tag=%s\n" ${GH_REPO_SLUG} ${GH_TAG}
8+
printf "\n>>>>> Publishing javadoc for release build: repo=%s tag=%s\n" ${GITHUB_REPO_SLUG} ${GITHUB_TAG}
99

1010
printf "\n>>>>> Cloning repository's gh-pages branch into directory 'gh-pages'\n"
1111
rm -fr ./gh-pages
1212
git config --global user.email "devxsdk@us.ibm.com"
1313
git config --global user.name "ibm-devx-sdk"
14-
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/IBM/${GH_REPO_SLUG}.git gh-pages
14+
git clone --branch=gh-pages https://${GITHUB_TOKEN}@github.com/${GITHUB_REPO_SLUG}.git gh-pages
1515

1616
printf "\n>>>>> Finished cloning...\n"
1717

1818
pushd gh-pages
1919

2020
# Create a new directory for this branch/tag and copy the javadocs there.
21-
printf "\n>>>>> Copying javadocs to new directory: docs/%s\n" ${GH_TAG}
22-
rm -rf docs/${GH_TAG}
23-
mkdir -p docs/${GH_TAG}
24-
cp -rf ../target/site/apidocs/* docs/${GH_TAG}
21+
printf "\n>>>>> Copying javadocs to new directory: docs/%s\n" ${GITHUB_TAG}
22+
rm -rf docs/${GITHUB_TAG}
23+
mkdir -p docs/${GITHUB_TAG}
24+
cp -rf ../target/site/apidocs/* docs/${GITHUB_TAG}
2525

2626
printf "\n>>>>> Generating gh-pages index.html...\n"
2727
../build/generateJavadocIndex.sh > index.html
2828

2929
printf "\n>>>>> Committing new javadoc...\n"
3030
git add -f .
31-
git commit -m "docs: latest javadoc for ${GH_TAG}"
31+
git commit -m "docs: latest javadoc for ${GITHUB_TAG}"
3232
git push -f origin gh-pages
3333

3434
popd
3535

36-
printf "\n>>>>> Published javadoc for release build: repo=%s tag=%s\n" ${GH_REPO_SLUG} ${GH_TAG}
36+
printf "\n>>>>> Published javadoc for release build: repo=%s tag=%s\n" ${GITHUB_REPO_SLUG} ${GITHUB_TAG}

build/publishJavadoc.sh

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
#!/bin/bash
2-
3-
# This script will publish the aggregated javadocs found in the project's "target" directory.
4-
# 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,
6-
7-
# Publish javadocs only for a tagged-release.
8-
if [[ -n "${TRAVIS_TAG}" ]]; then
9-
10-
printf "\n>>>>> Publishing javadoc for release build: repo=%s release=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_TAG} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER}
11-
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/IBM/continuous-delivery-java-sdk.git gh-pages
15-
16-
printf "\n>>>>> Finished cloning...\n"
17-
18-
pushd gh-pages
19-
20-
# Create a new directory for this branch/tag and copy the javadocs there.
21-
printf "\n>>>>> Copying javadocs to new directory: docs/%s\n" ${TRAVIS_TAG}
22-
rm -rf docs/${TRAVIS_TAG}
23-
mkdir -p docs/${TRAVIS_TAG}
24-
cp -rf ../target/site/apidocs/* docs/${TRAVIS_TAG}
25-
26-
printf "\n>>>>> Generating gh-pages index.html...\n"
27-
../build/generateJavadocIndex.sh > index.html
28-
29-
printf "\n>>>>> Committing new javadoc...\n"
30-
git add -f .
31-
git commit -m "docs: latest javadoc for ${TRAVIS_TAG} (${TRAVIS_COMMIT})"
32-
git push -f origin gh-pages
33-
34-
popd
35-
36-
printf "\n>>>>> Published javadoc for release build: repo=%s release=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_TAG} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER}
37-
38-
else
39-
40-
printf "\n>>>>> Javadoc publishing bypassed for non-release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER}
41-
42-
fi
1+
#!/bin/bash
2+
3+
# This script will publish the aggregated javadocs found in the project's "target" directory.
4+
# 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,
6+
7+
# Publish javadocs only for a tagged-release.
8+
if [[ -n "${TRAVIS_TAG}" ]]; then
9+
10+
printf "\n>>>>> Publishing javadoc for release build: repo=%s release=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_TAG} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER}
11+
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://${GITHUB_TOKEN}@github.com/IBM/continuous-delivery-java-sdk.git gh-pages
15+
16+
printf "\n>>>>> Finished cloning...\n"
17+
18+
pushd gh-pages
19+
20+
# Create a new directory for this branch/tag and copy the javadocs there.
21+
printf "\n>>>>> Copying javadocs to new directory: docs/%s\n" ${TRAVIS_TAG}
22+
rm -rf docs/${TRAVIS_TAG}
23+
mkdir -p docs/${TRAVIS_TAG}
24+
cp -rf ../target/site/apidocs/* docs/${TRAVIS_TAG}
25+
26+
printf "\n>>>>> Generating gh-pages index.html...\n"
27+
../build/generateJavadocIndex.sh > index.html
28+
29+
printf "\n>>>>> Committing new javadoc...\n"
30+
git add -f .
31+
git commit -m "docs: latest javadoc for ${TRAVIS_TAG} (${TRAVIS_COMMIT})"
32+
git push -f origin gh-pages
33+
34+
popd
35+
36+
printf "\n>>>>> Published javadoc for release build: repo=%s release=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_TAG} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER}
37+
38+
else
39+
40+
printf "\n>>>>> Javadoc publishing bypassed for non-release build: repo=%s branch=%s build_num=%s job_num=%s\n" ${TRAVIS_REPO_SLUG} ${TRAVIS_BRANCH} ${TRAVIS_BUILD_NUMBER} ${TRAVIS_JOB_NUMBER}
41+
42+
fi

0 commit comments

Comments
 (0)