Skip to content

Commit 52d770e

Browse files
edburnsCopilot
andcommitted
Fix gh-pages deployment: replace DEPLOY_VERSION, fix git clone approach
- Replace all DEPLOY_VERSION refs with inputs.version - Replace actions/checkout for gh-pages with git clone (avoids conflicts with parent .git from standalone checkout) - Use git clone --branch gh-pages with fallback to fresh git init - Remove -u flag from git push (not needed for force push) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 26f9302 commit 52d770e

1 file changed

Lines changed: 16 additions & 20 deletions

File tree

.github/workflows/deploy-site.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,36 +83,32 @@ jobs:
8383
# 5. Build the Maven Site using THIS repo's pom.xml + src/site/
8484
- name: Build documentation site
8585
run: |
86-
echo "Building site for version ${{ env.DEPLOY_VERSION }}"
86+
echo "Building site for version ${{ inputs.version }}"
8787
mvn site -Dsite.version=${{ inputs.version }} -B
8888
89-
# 6. Checkout gh-pages branch from this (standalone) repo
90-
- name: Checkout gh-pages branch
91-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
92-
with:
93-
ref: gh-pages
94-
path: site
95-
continue-on-error: true
96-
97-
- name: Initialize site if needed
89+
# 6. Prepare gh-pages deployment directory
90+
- name: Prepare gh-pages directory
9891
run: |
99-
if [ ! -d "site/.git" ]; then
100-
rm -rf site
92+
# Try to clone existing gh-pages branch (shallow)
93+
git clone --depth 1 --branch gh-pages \
94+
"https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" \
95+
site 2>/dev/null || {
96+
echo "No gh-pages branch exists yet, creating fresh"
10197
mkdir -p site
10298
cd site
10399
git init
104100
git checkout -b gh-pages
105-
git remote add origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
106-
fi
101+
}
107102
108103
# 7. Copy generated site to version directory
109104
- name: Deploy version documentation
110105
run: |
111-
echo "Deploying documentation for version ${DEPLOY_VERSION}"
106+
VERSION="${{ inputs.version }}"
107+
echo "Deploying documentation for version ${VERSION}"
112108
113-
rm -rf "site/${DEPLOY_VERSION}"
114-
mkdir -p "site/${DEPLOY_VERSION}"
115-
cp -r target/site/* "site/${DEPLOY_VERSION}/"
109+
rm -rf "site/${VERSION}"
110+
mkdir -p "site/${VERSION}"
111+
cp -r target/site/* "site/${VERSION}/"
116112
117113
# Also publish as /latest/ if requested
118114
if [[ "${{ inputs.publish_as_latest }}" == "true" ]]; then
@@ -187,10 +183,10 @@ jobs:
187183
188184
git add -A
189185
190-
COMMIT_MSG="Deploy documentation: ${DEPLOY_VERSION} (from ${{ inputs.monorepo_tag }})"
186+
COMMIT_MSG="Deploy documentation: ${{ inputs.version }} (from ${{ inputs.monorepo_tag }})"
191187
git diff --staged --quiet || git commit -m "$COMMIT_MSG"
192188
193-
git push -u origin gh-pages --force
189+
git push origin gh-pages --force
194190
env:
195191
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
196192

0 commit comments

Comments
 (0)