-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathaction.yml
More file actions
115 lines (103 loc) · 3.91 KB
/
action.yml
File metadata and controls
115 lines (103 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Build Cloud Posse Docs
inputs:
aws_region:
description: "AWS Region for credentials"
required: true
iam_role_arn:
description: "IAM Role ARN with access to S3 bucket origin"
required: true
iam_role_session_name:
description: "Session name to use to assume access to S3 bucket origin"
default: "cloudposse-docs-ci"
google_tag_manager:
description: "Google Tag Manager"
default: "GTM-ABCD123"
google_site_verification_id:
description: "Google Site verification ID"
default: "preview-github"
repo_access_token:
description: "GitHub Token used to access private repos"
required: true
skip_library_download:
description: "Skip downloading library docs from release (use when docs are already present)"
default: "false"
runs:
using: composite
steps:
# https://github.com/marketplace/actions/configure-aws-credentials-action-for-github-actions
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ inputs.aws_region }}
role-to-assume: ${{ inputs.iam_role_arn }}
role-session-name: ${{ inputs.iam_role_session_name }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: 'npm'
# Set same key to restore cache in all jobs
# Update key once a week - TTL on unused cache is 7 days
- name: Set Cache Key
id: cache-key
shell: bash
run: |
CURRENT_WEEK=$(date +'%Y-%U')
CACHE_KEY="build-website-cache-${CURRENT_WEEK}"
echo "result=${CACHE_KEY}" >> $GITHUB_OUTPUT
- name: Cache rendered content
if: ${{ !contains(github.event.*.labels.*.name, 'no-cache') }}
uses: actions/cache@v4
with:
path: |
.build-harness
key: ${{ steps.cache-key.outputs.result }}
- name: "Initialize Build Harness"
shell: bash
run: |
make init
# Download pre-built library docs from the most recent release (draft or published) that has the asset
# Uses GITHUB_TOKEN (separate rate limits from PAT) for release downloads
- name: "Download Pre-built Library Docs"
if: ${{ inputs.skip_library_download != 'true' }}
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
DOWNLOADED=false
# Get all releases (drafts and published) ordered by most recent first
echo "Searching for library-docs.tar.gz in releases..."
RELEASES=$(gh release list --repo ${{ github.repository }} --exclude-drafts=false --limit 20 | awk -F'\t' '{print $3}')
if [ -z "$RELEASES" ]; then
echo "Error: No releases found. Run the 'Generate Library' workflow first."
exit 1
fi
# Iterate through releases until we find one with library-docs.tar.gz
for TAG in $RELEASES; do
echo "Checking release: ${TAG}"
DOWNLOAD_OUTPUT=$(gh release download "${TAG}" \
--repo ${{ github.repository }} \
--pattern "library-docs.tar.gz" \
--dir /tmp 2>&1) && {
echo "Downloaded library docs from release: ${TAG}"
DOWNLOADED=true
break
} || {
echo " No library-docs.tar.gz in ${TAG}, trying next..."
echo " Debug: ${DOWNLOAD_OUTPUT}"
}
done
if [ "$DOWNLOADED" = false ]; then
echo "Error: No library-docs.tar.gz found in any release. Run the 'Generate Library' workflow first."
exit 1
fi
echo "Extracting library docs..."
tar -xzf /tmp/library-docs.tar.gz
echo "Library docs downloaded and extracted successfully"
- name: Install Dependencies and Build Website
shell: bash
env:
GOOGLE_TAG_MANAGER: ${{ inputs.google_tag_manager }}
GOOGLE_SITE_VERIFICATION_ID: ${{ inputs.google_site_verification_id }}
run: |
make build-production