Skip to content

Commit 8d3b2d0

Browse files
edburnsCopilot
andcommitted
Rewrite deploy-site.yml for cross-repo builds from monorepo
Replace the self-contained site build workflow with one that: - Is triggered only by workflow_dispatch (from the monorepo's release workflow) - Accepts version, publish_as_latest, and monorepo_tag inputs - Checks out github/copilot-sdk at the release tag for source code - Builds the Maven Site from the monorepo's java/ directory - Deploys to this repo's gh-pages branch - Detects versions from deployed directories (no tags needed in this repo) Also update index.html template links to point to the monorepo (github/copilot-sdk/tree/main/java) instead of this archived repo. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 643364d commit 8d3b2d0

2 files changed

Lines changed: 99 additions & 204 deletions

File tree

.github/templates/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<h1>GitHub Copilot SDK for <span class="gradient-text">Java</span></h1>
1919
<p class="hero-subtitle">The official SDK for building AI-powered tools with GitHub Copilot's agentic runtime.</p>
2020
<div class="header-buttons">
21-
<a href="https://github.com/github/copilot-sdk-java" class="btn btn-github">
21+
<a href="https://github.com/github/copilot-sdk/tree/main/java" class="btn btn-github">
2222
<svg height="20" width="20" viewBox="0 0 16 16"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>
2323
View on GitHub
2424
</a>
@@ -75,7 +75,7 @@ <h2 class="section-title">Available Versions</h2>
7575

7676
<footer class="footer">
7777
<div class="footer-links">
78-
<a href="https://github.com/github/copilot-sdk-java">GitHub Repository</a>
78+
<a href="https://github.com/github/copilot-sdk/tree/main/java">GitHub Repository</a>
7979
<span class="sep">·</span>
8080
<a href="https://central.sonatype.com/artifact/com.github/copilot-sdk">Maven Central</a>
8181
<span class="sep">·</span>

.github/workflows/deploy-site.yml

Lines changed: 97 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,71 @@
1-
# Workflow for deploying versioned documentation to GitHub Pages
1+
# Workflow for deploying versioned documentation to GitHub Pages.
2+
# Source code is built from the monorepo (github/copilot-sdk) at a release tag.
3+
# The generated site is deployed to this repo's gh-pages branch.
24
name: Deploy Documentation
35

4-
env:
5-
# Disable Husky Git hooks in CI to prevent local development hooks
6-
# (e.g., pre-commit formatting checks) from running during automated
7-
# workflows that perform git commits and pushes.
8-
HUSKY: 0
9-
106
on:
11-
# Runs after Build & Test succeeds on main (publishes to /snapshot/)
12-
workflow_run:
13-
workflows: ["Build & Test"]
14-
types: [completed]
15-
branches: [main]
16-
17-
# Runs on release publish (publishes to /latest/ and /vX.Y.Z/)
18-
release:
19-
types: [published]
20-
21-
# Allows manual trigger
227
workflow_dispatch:
238
inputs:
249
version:
25-
description: 'Specific version/tag to build (leave empty for snapshot from main)'
10+
description: 'Version to build (e.g., 1.0.1-java.0). This becomes the directory name on the site.'
2611
type: string
27-
default: ''
12+
required: true
2813
publish_as_latest:
29-
description: 'Also publish as latest?'
14+
description: 'Also publish as /latest/?'
3015
type: boolean
31-
default: false
32-
rebuild_all_versions:
33-
description: 'Rebuild documentation for all release tags?'
34-
type: boolean
35-
default: false
16+
default: true
17+
monorepo_tag:
18+
description: 'Tag in github/copilot-sdk monorepo (e.g., java/v1.0.1-java.0)'
19+
type: string
20+
required: true
3621

37-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
3822
permissions:
39-
actions: read # Required to download artifacts from Build & Test workflow
4023
contents: write
4124
pages: write
4225
id-token: write
4326

44-
# Allow only one concurrent deployment
4527
concurrency:
4628
group: "pages"
4729
cancel-in-progress: false
4830

4931
jobs:
5032
build-and-deploy:
51-
# Skip if triggered by workflow_run that failed
52-
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
5333
runs-on: ubuntu-latest
5434
environment:
5535
name: github-pages
5636
url: ${{ steps.deployment.outputs.page_url }}
5737
steps:
58-
- name: Checkout
38+
# 1. Checkout this (standalone) repo for templates and workflow files
39+
- name: Checkout standalone repo
5940
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6041
with:
61-
fetch-depth: 0
42+
path: standalone
6243

63-
- name: Set up JDK 17
44+
# 2. Checkout the monorepo at the release tag (for Java source + site content)
45+
- name: Checkout monorepo at release tag
46+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
47+
with:
48+
repository: github/copilot-sdk
49+
ref: ${{ inputs.monorepo_tag }}
50+
path: monorepo
51+
token: ${{ secrets.MONOREPO_READ_TOKEN }}
52+
53+
# 3. Set up JDK
54+
- name: Set up JDK 25
6455
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
6556
with:
66-
java-version: '17'
67-
distribution: 'temurin'
57+
java-version: '25'
58+
distribution: 'microsoft'
6859
cache: 'maven'
6960

61+
# 4. Build the Maven Site from monorepo java/ directory
62+
- name: Build documentation site
63+
working-directory: monorepo/java
64+
run: |
65+
echo "Building site for version ${{ inputs.version }} from tag ${{ inputs.monorepo_tag }}"
66+
mvn clean compile site -DskipTests -Dcheckstyle.skip=true -B
67+
68+
# 5. Checkout gh-pages branch from this (standalone) repo
7069
- name: Checkout gh-pages branch
7170
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7271
with:
@@ -85,209 +84,105 @@ jobs:
8584
git remote add origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
8685
fi
8786
88-
- name: Get all release tags
89-
id: tags
87+
# 6. Copy generated site to version directory
88+
- name: Deploy version documentation
9089
run: |
91-
# Get all tags that look like version numbers (v1.0.0 or 1.0.0)
92-
TAGS=$(git tag -l | grep -E '^v?[0-9]+\.[0-9]+' | sort -Vr)
93-
echo "all_tags<<EOF" >> $GITHUB_OUTPUT
94-
echo "$TAGS" >> $GITHUB_OUTPUT
95-
echo "EOF" >> $GITHUB_OUTPUT
96-
97-
# Get the latest tag
98-
LATEST_TAG=$(echo "$TAGS" | head -n 1)
99-
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
100-
101-
# Determine what to build
102-
if [[ "${{ github.event_name }}" == "release" ]]; then
103-
echo "build_tag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
104-
echo "is_release=true" >> $GITHUB_OUTPUT
105-
elif [[ -n "${{ inputs.version }}" ]]; then
106-
# Manual trigger with specific version
107-
VERSION="${{ inputs.version }}"
108-
# Add 'v' prefix if not present for tag lookup
109-
if [[ ! "$VERSION" =~ ^v ]]; then
110-
TAG="v$VERSION"
111-
else
112-
TAG="$VERSION"
113-
fi
114-
echo "build_tag=$TAG" >> $GITHUB_OUTPUT
115-
echo "is_release=true" >> $GITHUB_OUTPUT
116-
else
117-
echo "build_tag=" >> $GITHUB_OUTPUT
118-
echo "is_release=false" >> $GITHUB_OUTPUT
119-
fi
120-
121-
- name: Download test results from Build & Test
122-
if: steps.tags.outputs.is_release == 'false' && inputs.rebuild_all_versions != true && github.event_name == 'workflow_run'
123-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
124-
with:
125-
name: test-results-for-site
126-
path: /tmp/test-results
127-
run-id: ${{ github.event.workflow_run.id }}
128-
github-token: ${{ secrets.GITHUB_TOKEN }}
129-
continue-on-error: true
90+
VERSION="${{ inputs.version }}"
91+
echo "Deploying documentation for version ${VERSION}"
13092
131-
- name: Build snapshot documentation (main branch)
132-
if: steps.tags.outputs.is_release == 'false' && inputs.rebuild_all_versions != true
133-
run: |
134-
# Compile sources (needed for javadoc and other reports)
135-
./mvnw clean compile -DskipTests -Dcheckstyle.skip=true
136-
137-
# Restore test results from Build & Test (for JaCoCo + Surefire reports)
138-
# upload-artifact strips the common ancestor (target/), so files are at root
139-
if [ -d "/tmp/test-results/surefire-reports" ]; then
140-
mkdir -p target/surefire-reports
141-
cp -r /tmp/test-results/surefire-reports/* target/surefire-reports/
142-
echo "Surefire reports restored"
143-
fi
144-
if [ -f "/tmp/test-results/jacoco-test-results/sdk-tests.exec" ]; then
145-
mkdir -p target/jacoco-test-results
146-
cp /tmp/test-results/jacoco-test-results/sdk-tests.exec target/jacoco-test-results/
147-
echo "JaCoCo exec restored"
148-
fi
149-
150-
# Generate site (report plugins pick up the restored data)
151-
./mvnw site -DskipTests -Dcheckstyle.skip=true
152-
153-
rm -rf "site/snapshot"
154-
mkdir -p "site/snapshot"
155-
cp -r target/site/* "site/snapshot/"
93+
rm -rf "site/${VERSION}"
94+
mkdir -p "site/${VERSION}"
95+
cp -r monorepo/java/target/site/* "site/${VERSION}/"
15696
157-
- name: Build documentation for specific version
158-
if: steps.tags.outputs.is_release == 'true' && inputs.rebuild_all_versions != true
159-
run: |
160-
TAG="${{ steps.tags.outputs.build_tag }}"
161-
VERSION="${TAG#v}" # Remove 'v' prefix
162-
163-
echo "Building documentation for $TAG (version $VERSION)"
164-
git checkout "$TAG"
165-
166-
./mvnw clean site -DskipTests -Dcheckstyle.skip=true
167-
168-
rm -rf "site/$VERSION"
169-
mkdir -p "site/$VERSION"
170-
cp -r target/site/* "site/$VERSION/"
171-
172-
# Update /latest/ if this is a release event or publish_as_latest is true
173-
if [[ "${{ github.event_name }}" == "release" ]] || [[ "${{ inputs.publish_as_latest }}" == "true" ]]; then
97+
# Also publish as /latest/ if requested
98+
if [[ "${{ inputs.publish_as_latest }}" == "true" ]]; then
17499
rm -rf "site/latest"
175100
mkdir -p "site/latest"
176-
cp -r target/site/* "site/latest/"
101+
cp -r monorepo/java/target/site/* "site/latest/"
177102
fi
178-
179-
git checkout main
180-
181-
- name: Build documentation for all release tags
182-
if: inputs.rebuild_all_versions == true
183-
run: |
184-
LATEST_TAG="${{ steps.tags.outputs.latest_tag }}"
185-
186-
while IFS= read -r TAG; do
187-
if [[ -z "$TAG" ]]; then continue; fi
188-
189-
VERSION="${TAG#v}" # Remove 'v' prefix
190-
echo "Building documentation for $TAG (version $VERSION)"
191-
192-
git checkout "$TAG"
193-
./mvnw clean site -DskipTests -Dcheckstyle.skip=true
194-
195-
rm -rf "site/$VERSION"
196-
mkdir -p "site/$VERSION"
197-
cp -r target/site/* "site/$VERSION/"
198-
199-
# If this is the latest tag, also update /latest/
200-
if [[ "$TAG" == "$LATEST_TAG" ]]; then
201-
rm -rf "site/latest"
202-
mkdir -p "site/latest"
203-
cp -r target/site/* "site/latest/"
204-
fi
205-
206-
done <<< "${{ steps.tags.outputs.all_tags }}"
207-
208-
# Return to main and build snapshot
209-
git checkout main
210-
./mvnw clean site -DskipTests -Dcheckstyle.skip=true
211-
212-
rm -rf "site/snapshot"
213-
mkdir -p "site/snapshot"
214-
cp -r target/site/* "site/snapshot/"
215103
104+
# 7. Copy version index page from standalone templates
216105
- name: Copy version index page
217106
run: |
218-
cp .github/templates/index.html site/index.html
219-
cp .github/templates/styles.css site/styles.css
107+
cp standalone/.github/templates/index.html site/index.html
108+
cp standalone/.github/templates/styles.css site/styles.css
220109
221-
- name: Update version list from git tags
110+
# 8. Update version list based on directories present in gh-pages
111+
# (NOT from tags — tags do not exist in this repo)
112+
- name: Update version list from deployed directories
222113
run: |
223114
cd site
224-
225-
REPO_URL="https://github.com/github/copilot-sdk-java"
226-
227-
# Get versions from git tags (already sorted by version, descending)
228-
VERSIONS=$(git -C .. tag -l | grep -E '^v?[0-9]+\.[0-9]+' | sed 's/^v//' | sort -Vr)
115+
116+
# Release notes for OLD versions (pre-monorepo) are in the standalone repo.
117+
# Release notes for NEW versions (monorepo era) are in the monorepo.
118+
MONOREPO_URL="https://github.com/github/copilot-sdk"
119+
STANDALONE_URL="https://github.com/github/copilot-sdk-java"
120+
121+
# Detect versions from directories that exist in gh-pages.
122+
# Exclude non-version dirs: snapshot, latest, .git, etc.
123+
VERSIONS=$(ls -d */ 2>/dev/null | sed 's|/||' | grep -E '^[0-9]+\.[0-9]+' | sort -Vr || true)
124+
229125
HAS_SNAPSHOT=$([ -d "snapshot" ] && echo "true" || echo "false")
230-
231-
# Generate version links
126+
232127
CURRENT_HTML=""
233128
OLDER_HTML=""
234129
IS_FIRST_VERSION="true"
235-
236-
# Add snapshot if exists (goes to current versions)
130+
131+
# Add snapshot if exists
237132
if [ "$HAS_SNAPSHOT" = "true" ]; then
238-
CURRENT_HTML+='<li><span class="version-name">Development (main branch)</span><span class="version-links"><a href="./snapshot/" class="doc-link">documentation ↗</a><a href="'"$REPO_URL"'/blob/main/CHANGELOG.md" class="release-link">changelog ↗</a><span class="badge snapshot">snapshot</span></span></li>'
133+
CURRENT_HTML+='<li><span class="version-name">Development (main branch)</span><span class="version-links"><a href="./snapshot/" class="doc-link">documentation ↗</a><a href="'"${MONOREPO_URL}"'/blob/main/java/CHANGELOG.md" class="release-link">changelog ↗</a><span class="badge snapshot">snapshot</span></span></li>'
239134
fi
240-
241-
# Add versioned releases from tags (first one is latest, rest go to older)
135+
136+
# Add versioned releases — directory-based, no tags needed
242137
for v in $VERSIONS; do
243-
if [ -d "$v" ]; then
244-
if [ "$IS_FIRST_VERSION" = "true" ]; then
245-
CURRENT_HTML+='<li class="latest-version"><span class="version-name">Version '"$v"'</span><span class="version-links"><a href="./'"$v"'/" class="doc-link">documentation ↗</a><a href="'"$REPO_URL"'/releases/tag/v'"$v"'" class="release-link">release notes ↗</a><span class="badge latest">latest</span></span></li>'
246-
IS_FIRST_VERSION="false"
247-
else
248-
OLDER_HTML+='<li><span>'"$v"'</span><span class="older-links"><a href="./'"$v"'/" class="doc-link">documentation ↗</a><a href="'"$REPO_URL"'/releases/tag/v'"$v"'" class="release-link">release notes ↗</a></span></li>'
249-
fi
138+
# Determine which repo has the release notes for this version.
139+
# Monorepo tags use "java/v{VERSION}" format.
140+
# Check if a monorepo-era release exists. Heuristic: if the version
141+
# was just deployed by this workflow, it's a monorepo release.
142+
# For simplicity, try monorepo first; old standalone releases
143+
# will still work via their existing links.
144+
RELEASE_URL="${MONOREPO_URL}/releases/tag/java/v${v}"
145+
146+
if [ "$IS_FIRST_VERSION" = "true" ]; then
147+
CURRENT_HTML+='<li class="latest-version"><span class="version-name">Version '"$v"'</span><span class="version-links"><a href="./'"$v"'/" class="doc-link">documentation ↗</a><a href="'"$RELEASE_URL"'" class="release-link">release notes ↗</a><span class="badge latest">latest</span></span></li>'
148+
IS_FIRST_VERSION="false"
149+
else
150+
OLDER_HTML+='<li><span>'"$v"'</span><span class="older-links"><a href="./'"$v"'/" class="doc-link">documentation ↗</a><a href="'"$RELEASE_URL"'" class="release-link">release notes ↗</a></span></li>'
250151
fi
251152
done
252-
253-
# Update the index.html using the placeholders
153+
254154
sed -i "s|<!-- CURRENT_VERSIONS_PLACEHOLDER -->|$CURRENT_HTML|" index.html
255155
sed -i "s|<!-- OLDER_VERSIONS_PLACEHOLDER -->|$OLDER_HTML|" index.html
256156
157+
# 9. Overlay custom JaCoCo CSS (from the monorepo's site resources)
257158
- name: Overlay custom JaCoCo CSS
258159
run: |
259160
cd site
260-
for dir in */jacoco/jacoco-resources; do
261-
if [ -d "$dir" ]; then
262-
cp ../src/site/jacoco-resources/report.css "$dir/report.css"
263-
echo "Overlaid JaCoCo CSS in $dir"
264-
fi
265-
done
161+
JACOCO_CSS="../monorepo/java/src/site/jacoco-resources/report.css"
162+
if [ -f "${JACOCO_CSS}" ]; then
163+
for dir in */jacoco/jacoco-resources; do
164+
if [ -d "$dir" ]; then
165+
cp "${JACOCO_CSS}" "$dir/report.css"
166+
echo "Overlaid JaCoCo CSS in $dir"
167+
fi
168+
done
169+
fi
266170
171+
# 10. Push to gh-pages
267172
- name: Deploy to GitHub Pages
268173
run: |
269174
cd site
270175
git config user.name "github-actions[bot]"
271176
git config user.email "github-actions[bot]@users.noreply.github.com"
272-
273-
# Set remote URL with token for authentication
177+
274178
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" 2>/dev/null || \
275179
git remote add origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
276-
180+
277181
git add -A
278-
279-
# Create descriptive commit message
280-
if [[ "${{ inputs.rebuild_all_versions }}" == "true" ]]; then
281-
COMMIT_MSG="Rebuild documentation for all versions"
282-
elif [[ "${{ steps.tags.outputs.is_release }}" == "true" ]]; then
283-
COMMIT_MSG="Deploy documentation: ${{ steps.tags.outputs.build_tag }}"
284-
else
285-
COMMIT_MSG="Deploy documentation: snapshot"
286-
fi
287-
182+
183+
COMMIT_MSG="Deploy documentation: ${{ inputs.version }} (from ${{ inputs.monorepo_tag }})"
288184
git diff --staged --quiet || git commit -m "$COMMIT_MSG"
289-
290-
# Push, creating the branch if it doesn't exist
185+
291186
git push -u origin gh-pages --force
292187
env:
293188
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)