Repository navigation
142 lines (121 loc) · 4.94 KB
/
Copy pathdeploy_docs_v2.yml
File metadata and controls
142 lines (121 loc) · 4.94 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
name: Deploy Tiny Docs v2
on:
workflow_dispatch:
inputs:
environment:
description: 'Deployment Environment'
required: true
default: 'staging'
type: choice
options:
- 'staging'
- 'production'
# Need ID token write permission to use OIDC
permissions:
id-token: write
env:
TARGET: ${{ inputs.environment || 'staging' }}
ACCT: ${{ inputs.environment == 'production' && '990880627107' || '327995277200' }}
BUCKET: ${{ inputs.environment == 'production' && 'tiny-cloud-antora-docs-release' || 'tiny-cloud-antora-docs-preview' }}
RUN: run-${{ github.run_number }}-${{ github.run_attempt }}
jobs:
build:
name: Build Docs and Deploy
if: github.repository == 'tinymce/tinymce-docs' && github.repository_owner == 'tinymce'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout branch
uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v5
with:
cache: 'yarn'
node-version: 22
- name: Install dependencies
run: yarn install
- name: Build Website
run: yarn antora ./antora-playbook.yml
- name: Generate markdown for agents
run: yarn build:markdown build/site
- name: Generate LLM files
run: yarn generate-llm-files build/site
- name: Rename site folder to docs
run: |
mv ./build/site ./build/docs
- name: Rename sitemap.xml to antora-sitemap.xml
run: |
mv ./build/docs/sitemap.xml ./build/docs/antora-sitemap.xml
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: 'arn:aws:iam::${{ env.ACCT }}:role/${{ env.TARGET }}-tinymce-docs-update'
role-session-name: tinymce-docs-${{ env.TARGET }}-release
aws-region: us-east-1
# Markdown and plain-text files cannot declare their own encoding the way
# HTML does with <meta charset>, so the charset must be in the content type.
# Without it, browsers decode the UTF-8 files as Windows-1252 and show an
# em dash as "—". The sync guesses the type with no charset, so these files
# are uploaded separately with the type set explicitly.
- name: Upload website to S3
run: |
aws s3 sync ./build s3://${BUCKET}/main/${RUN} \
--exclude "*/index.html" \
--exclude "*.md" \
--exclude "*.txt" \
--cache-control "public, max-age=3600, stale-if-error=3600, stale-while-revalidate=86400"
aws s3 sync ./build s3://${BUCKET}/main/${RUN} \
--exclude "*" \
--include "*/index.html" \
--cache-control "max-age=300, stale-if-error=3600, stale-while-revalidate=86400"
aws s3 sync ./build s3://${BUCKET}/main/${RUN} \
--exclude "*" \
--include "*/index.md" \
--content-type "text/markdown; charset=utf-8" \
--cache-control "max-age=300, stale-if-error=3600, stale-while-revalidate=86400"
aws s3 sync ./build s3://${BUCKET}/main/${RUN} \
--exclude "*" \
--include "*.md" \
--exclude "*/index.md" \
--content-type "text/markdown; charset=utf-8" \
--cache-control "public, max-age=3600, stale-if-error=3600, stale-while-revalidate=86400"
aws s3 sync ./build s3://${BUCKET}/main/${RUN} \
--exclude "*" \
--include "*.txt" \
--content-type "text/plain; charset=utf-8" \
--cache-control "public, max-age=3600, stale-if-error=3600, stale-while-revalidate=86400"
# Attachment PDFs, such as the accessibility conformance reports, are served
# as downloads rather than rendered inline. The metadata directive replaces
# the full metadata set, so the cache headers set by the sync above must be
# restated here or they are lost.
- name: Serve attachment PDFs as downloads
run: |
aws s3 cp \
s3://${BUCKET}/main/${RUN}/ \
s3://${BUCKET}/main/${RUN}/ \
--recursive \
--exclude "*" \
--include "*/_attachments/*.pdf" \
--metadata-directive REPLACE \
--content-type application/pdf \
--content-disposition attachment \
--cache-control "public, max-age=3600, stale-if-error=3600, stale-while-revalidate=86400"
- name: Create redirects on S3
uses: tinymce/tinymce-docs-generate-redirects-action@v1.0
with:
build: ./build/
redirects: ./redirects.json
bucket: ${{ env.BUCKET }}
prefix: main/${{ env.RUN }}
parallel: 10
- name: Update pointer to current run output
run: |
aws s3api put-object --bucket ${BUCKET} --key main/index.html --body .github/workflows/resources/empty.html --content-type text/html --metadata pointer=${RUN}
- name: Tag old versions for cleanup
uses: tinymce/tinymce-docs-cleanup-action@v1.0
with:
bucket: ${{ env.BUCKET }}
folder: main
parallel: 20