Skip to content

Commit 534affb

Browse files
authored
Fix deploy-site.yml: validate inputs/secrets, use DEPLOY_VERSION in commit message
1 parent 73c8d09 commit 534affb

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

.github/workflows/deploy-site.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88
inputs:
99
version:
10-
description: 'Version to build (e.g., 1.0.1-java.0). This becomes the directory name on the site.'
10+
description: 'Version to build in tag format (e.g., java/v1.0.1-java.0). The java/v prefix is stripped to form the site directory name.'
1111
type: string
1212
required: true
1313
publish_as_latest:
@@ -35,6 +35,27 @@ jobs:
3535
name: github-pages
3636
url: ${{ steps.deployment.outputs.page_url }}
3737
steps:
38+
# 0. Validate required secrets and inputs
39+
- name: Validate inputs and secrets
40+
env:
41+
MONOREPO_READ_TOKEN: ${{ secrets.MONOREPO_READ_TOKEN }}
42+
run: |
43+
if [[ -z "${MONOREPO_READ_TOKEN}" ]]; then
44+
echo "::error::MONOREPO_READ_TOKEN secret is required but not configured."
45+
exit 1
46+
fi
47+
VERSION="${{ inputs.version }}"
48+
if [[ "${VERSION}" != java/v* ]]; then
49+
echo "::error::VERSION must start with 'java/v' (got: '${VERSION}')"
50+
exit 1
51+
fi
52+
if [[ "${VERSION}" == *"../"* ]]; then
53+
echo "::error::VERSION must not contain '../'"
54+
exit 1
55+
fi
56+
DEPLOY_VERSION="${VERSION#java/v}"
57+
echo "DEPLOY_VERSION=${DEPLOY_VERSION}" >> "$GITHUB_ENV"
58+
3859
# 1. Checkout this (standalone) repo — has src/site/, pom.xml, templates
3960
- name: Checkout standalone repo
4061
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -66,8 +87,8 @@ jobs:
6687
# 5. Build the Maven Site using THIS repo's pom.xml + src/site/
6788
- name: Build documentation site
6889
run: |
69-
echo "Building site for version ${{ inputs.version }}"
70-
mvn site -Dsite.version=${{ inputs.version }} -B
90+
echo "Building site for version ${{ env.DEPLOY_VERSION }}"
91+
mvn site -Dsite.version=${{ env.DEPLOY_VERSION }} -B
7192
7293
# 6. Checkout gh-pages branch from this (standalone) repo
7394
- name: Checkout gh-pages branch
@@ -91,12 +112,11 @@ jobs:
91112
# 7. Copy generated site to version directory
92113
- name: Deploy version documentation
93114
run: |
94-
VERSION="${{ inputs.version }}"
95-
echo "Deploying documentation for version ${VERSION}"
115+
echo "Deploying documentation for version ${DEPLOY_VERSION}"
96116
97-
rm -rf "site/${VERSION}"
98-
mkdir -p "site/${VERSION}"
99-
cp -r target/site/* "site/${VERSION}/"
117+
rm -rf "site/${DEPLOY_VERSION}"
118+
mkdir -p "site/${DEPLOY_VERSION}"
119+
cp -r target/site/* "site/${DEPLOY_VERSION}/"
100120
101121
# Also publish as /latest/ if requested
102122
if [[ "${{ inputs.publish_as_latest }}" == "true" ]]; then
@@ -171,7 +191,7 @@ jobs:
171191
172192
git add -A
173193
174-
COMMIT_MSG="Deploy documentation: ${{ inputs.version }} (from ${{ inputs.monorepo_tag }})"
194+
COMMIT_MSG="Deploy documentation: ${DEPLOY_VERSION} (from ${{ inputs.monorepo_tag }})"
175195
git diff --staged --quiet || git commit -m "$COMMIT_MSG"
176196
177197
git push -u origin gh-pages --force

0 commit comments

Comments
 (0)