Skip to content

Commit 17710ef

Browse files
milldrclaude
andauthored
fix: use workflow artifacts for library docs in release workflow (#861)
Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent aa49952 commit 17710ef

File tree

3 files changed

+44
-22
lines changed

3 files changed

+44
-22
lines changed

.github/actions/build-website/action.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ inputs:
1818
repo_access_token:
1919
description: "GitHub Token used to access private repos"
2020
required: true
21+
skip_library_download:
22+
description: "Skip downloading library docs from release (use when docs are already present)"
23+
default: "false"
2124

2225
runs:
2326
using: composite
@@ -59,44 +62,42 @@ runs:
5962
run: |
6063
make init
6164
62-
# Download pre-built library docs from draft release or latest published release
65+
# Download pre-built library docs from the most recent release (draft or published) that has the asset
6366
- name: "Download Pre-built Library Docs"
67+
if: ${{ inputs.skip_library_download != 'true' }}
6468
shell: bash
6569
env:
6670
GH_TOKEN: ${{ inputs.repo_access_token }}
6771
run: |
6872
DOWNLOADED=false
6973
70-
# Try draft release first
71-
echo "Checking for draft release..."
72-
DRAFT_TAG=$(gh release list --repo ${{ github.repository }} --exclude-drafts=false --limit 20 | { grep "Draft" || true; } | head -1 | awk -F'\t' '{print $3}')
74+
# Get all releases (drafts and published) ordered by most recent first
75+
echo "Searching for library-docs.tar.gz in releases..."
76+
RELEASES=$(gh release list --repo ${{ github.repository }} --exclude-drafts=false --limit 20 | awk -F'\t' '{print $3}')
7377
74-
if [ -n "$DRAFT_TAG" ]; then
75-
echo "Found draft release: ${DRAFT_TAG}"
76-
if gh release download "${DRAFT_TAG}" \
78+
if [ -z "$RELEASES" ]; then
79+
echo "Error: No releases found. Run the 'Generate Library' workflow first."
80+
exit 1
81+
fi
82+
83+
# Iterate through releases until we find one with library-docs.tar.gz
84+
for TAG in $RELEASES; do
85+
echo "Checking release: ${TAG}"
86+
if gh release download "${TAG}" \
7787
--repo ${{ github.repository }} \
7888
--pattern "library-docs.tar.gz" \
7989
--dir /tmp 2>/dev/null; then
80-
echo "Downloaded library docs from draft release"
90+
echo "Downloaded library docs from release: ${TAG}"
8191
DOWNLOADED=true
92+
break
8293
else
83-
echo "Draft release exists but has no library-docs.tar.gz asset"
94+
echo " No library-docs.tar.gz in ${TAG}, trying next..."
8495
fi
85-
else
86-
echo "No draft release found"
87-
fi
96+
done
8897
89-
# Fall back to latest published release
9098
if [ "$DOWNLOADED" = false ]; then
91-
echo "Downloading from latest published release..."
92-
if ! gh release download \
93-
--repo ${{ github.repository }} \
94-
--pattern "library-docs.tar.gz" \
95-
--dir /tmp; then
96-
echo "Error: No library-docs.tar.gz found in any release. Run the 'Generate Library' workflow first."
97-
exit 1
98-
fi
99-
echo "Downloaded library docs from latest published release"
99+
echo "Error: No library-docs.tar.gz found in any release. Run the 'Generate Library' workflow first."
100+
exit 1
100101
fi
101102
102103
echo "Extracting library docs..."

.github/workflows/generate-library.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ jobs:
216216
docs/modules/library \
217217
docs/github-actions/library
218218
219+
# Upload as workflow artifact for use by calling workflows (e.g., website-deploy-release)
220+
- name: Upload Library Docs Artifact
221+
uses: actions/upload-artifact@v4
222+
with:
223+
name: library-docs
224+
path: library-docs.tar.gz
225+
retention-days: 1
226+
219227
- name: Upload to Draft Release
220228
env:
221229
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/website-deploy-release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ jobs:
4545
with:
4646
fetch-depth: 0
4747

48+
# Download library docs generated by the generate-library-docs job
49+
- name: Download Library Docs Artifact
50+
uses: actions/download-artifact@v4
51+
with:
52+
name: library-docs
53+
54+
- name: Extract Library Docs
55+
run: |
56+
echo "Extracting library docs from workflow artifact..."
57+
tar -xzvf library-docs.tar.gz
58+
echo "Library docs extracted successfully"
59+
4860
- name: Build Website
4961
uses: ./.github/actions/build-website
5062
with:
@@ -54,6 +66,7 @@ jobs:
5466
google_tag_manager: ${{ env.GOOGLE_TAG_MANAGER }}
5567
google_site_verification_id: ${{ env.GOOGLE_SITE_VERIFICATION_ID }}
5668
repo_access_token: ${{ secrets.REPO_ACCESS_TOKEN }}
69+
skip_library_download: "true"
5770

5871
# "assets/refarch/handoffs/*" are handled by cloudposse-corp/demos
5972
- name: Copy Website to S3 Bucket

0 commit comments

Comments
 (0)