-
Notifications
You must be signed in to change notification settings - Fork 40
225 lines (202 loc) · 7.64 KB
/
Copy pathdocs.yml
File metadata and controls
225 lines (202 loc) · 7.64 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Docs
on:
release:
# A stable release publishes docs. A prerelease still builds the docs and
# checks the deploy credentials, but does not publish. "released" also
# catches promotion of an existing prerelease to stable.
types: [published, released]
workflow_call:
inputs:
build_docs:
description: "Build and verify the documentation"
required: false
type: boolean
default: true
check_credentials:
description: "Check the docs deploy AWS credentials"
required: false
type: boolean
default: false
version:
description: "Documentation version (e.g. v0.1.0)"
required: false
type: string
upload_artifact:
description: "Upload the generated docs as a workflow artifact"
required: false
type: boolean
default: true
artifact_name:
description: "Name of the uploaded docs artifact"
required: false
type: string
default: livekit-cpp-docs
artifact_retention_days:
description: "Artifact retention in days"
required: false
type: number
default: 7
secrets:
DOCS_DEPLOY_AWS_ACCESS_KEY:
required: false
DOCS_DEPLOY_AWS_API_SECRET:
required: false
outputs:
project_number:
description: "Doxygen PROJECT_NUMBER used for the build"
value: ${{ jobs.build.outputs.project_number }}
artifact_name:
description: "Uploaded docs artifact name"
value: ${{ jobs.build.outputs.artifact_name }}
permissions:
contents: read
actions: read
jobs:
build:
name: Generate and verify docs
if: github.event_name == 'release' || inputs.build_docs
runs-on: ubuntu-latest
outputs:
project_number: ${{ steps.build_docs.outputs.project_number }}
artifact_name: ${{ steps.artifact_meta.outputs.name }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Required so git describe in generate-docs.sh can resolve a version.
fetch-depth: 0
- name: Install Doxygen
run: |
sudo apt-get update
sudo apt-get install -y doxygen graphviz
- name: Generate docs
id: build_docs
shell: bash
env:
INPUT_VERSION: ${{ github.event_name == 'release' && github.event.release.tag_name || inputs.version || '' }}
run: |
set -euo pipefail
args=()
if [[ -n "$INPUT_VERSION" ]]; then
args+=(--version "$INPUT_VERSION")
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
args+=(--version "${{ github.ref_name }}")
fi
./scripts/generate-docs.sh "${args[@]}"
- name: Print docs version
shell: bash
run: |
set -euo pipefail
PROJECT_NUMBER="${{ steps.build_docs.outputs.project_number }}"
if [[ -z "$PROJECT_NUMBER" ]]; then
echo "ERROR: build_docs step did not emit a project_number output."
exit 1
fi
echo "Docs version: ${PROJECT_NUMBER}"
{
echo "Docs version: \`${PROJECT_NUMBER}\`"
echo ""
echo "> Note: On a non-tag/release run, the version resolves to:"
echo " \`<closest tag>-<commits since tag>-<commit sha>\`"
} >>"$GITHUB_STEP_SUMMARY"
- name: Verify docs were generated
shell: bash
run: |
set -euo pipefail
if [[ ! -f docs/doxygen/html/index.html ]]; then
echo "ERROR: Expected docs at docs/doxygen/html/index.html but file not found."
exit 1
fi
- name: Resolve artifact metadata
id: artifact_meta
if: github.event_name == 'release' || inputs.upload_artifact
shell: bash
env:
INPUT_NAME: ${{ inputs.artifact_name || format('livekit-cpp-docs-{0}', github.run_id) }}
INPUT_RETENTION: ${{ inputs.artifact_retention_days || 7 }}
run: |
set -euo pipefail
if [[ -z "$INPUT_NAME" ]]; then
echo "ERROR: Artifact name resolved to empty."
exit 1
fi
echo "name=${INPUT_NAME}" >>"$GITHUB_OUTPUT"
echo "retention=${INPUT_RETENTION}" >>"$GITHUB_OUTPUT"
- name: Upload docs artifact
if: steps.artifact_meta.outputs.name != ''
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ steps.artifact_meta.outputs.name }}
path: docs/doxygen/html/
retention-days: ${{ steps.artifact_meta.outputs.retention }}
if-no-files-found: error
- name: Re-download artifact
if: steps.artifact_meta.outputs.name != ''
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ steps.artifact_meta.outputs.name }}
path: html
- name: Verify downloaded artifact
if: steps.artifact_meta.outputs.name != ''
shell: bash
run: |
set -euo pipefail
TOTAL=$(find html -type f | wc -l | tr -d ' ')
echo "Total files: ${TOTAL}"
if [[ ! -f html/index.html ]]; then
echo "ERROR: html/index.html is missing; the publish artifact layout regressed."
exit 1
fi
credentials:
name: Check AWS credentials
# CI enables this only for trusted main pushes. Release events always
# check credentials before publishing. PR jobs never receive deploy keys.
if: github.event_name == 'release' || inputs.check_credentials
runs-on: ubuntu-latest
steps:
- name: Verify docs deploy credentials
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }}
AWS_DEFAULT_REGION: "us-east-1"
run: |
set -euo pipefail
if [[ -z "${AWS_ACCESS_KEY_ID}" || -z "${AWS_SECRET_ACCESS_KEY}" ]]; then
echo "Docs deploy AWS credentials are not available to this workflow."
exit 1
fi
aws sts get-caller-identity --query Arn --output text
publish:
name: Publish (S3 + CloudFront)
needs: [build, credentials]
if: github.event_name == 'release' && github.event.release.prerelease == false
runs-on: ubuntu-latest
steps:
- name: Download docs artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.build.outputs.artifact_name }}
path: html
- name: S3 Upload
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }}
AWS_DEFAULT_REGION: "us-east-1"
run: |
set -euo pipefail
if [[ ! -f html/index.html ]]; then
echo "Expected docs at html/index.html but file not found."
exit 1
fi
VERSIONED_PREFIX="s3://livekit-docs/client-sdk-cpp/${{ needs.build.outputs.project_number }}"
LATEST_PREFIX="s3://livekit-docs/client-sdk-cpp"
aws s3 cp html/ "$VERSIONED_PREFIX" --recursive
aws s3 cp html/ "$LATEST_PREFIX" --recursive
- name: Invalidate CloudFront cache
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }}
AWS_DEFAULT_REGION: "us-east-1"
run: |
aws cloudfront create-invalidation \
--distribution-id EJJ40KLJ3TRY9 \
--paths "/client-sdk-cpp/*"