Skip to content

Commit c6793da

Browse files
authored
TCLOUD-4860: Create a workflow for releasing docs (#3943)
* TCLOUD-4860: Create a workflow for releasing docs * TCLOUD-4860: Trigger action first time so it can be triggered manually * TCLOUD-4860: Re-enable upload features; leave push trigger for now * TCLOUD-4860: Add id-token write permission for OIDC * TCLOUD-4860: Try a tweak to read the environment input * TCLOUD-4860: Work around inputs limitation The inputs are only available for a dispatch event. * TCLOUD-4860: Another attempt to get a default input value * TCLOUD-4860: Fixed typo * TCLOUD-4860: Add cloudfront invalidation step * TCLOUD-4860: Remove unneeded env var * TCLOUD-4860: Remove push trigger * TCLOUD-4860: Update version of cleanup action
1 parent ece2fa1 commit c6793da

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Deploy Tiny Docs v2
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
environment:
7+
description: 'Deployment Environment'
8+
required: true
9+
default: 'staging'
10+
type: choice
11+
options:
12+
- 'staging'
13+
- 'production'
14+
15+
# Need ID token write permission to use OIDC
16+
permissions:
17+
id-token: write
18+
19+
env:
20+
TARGET: ${{ inputs.environment || 'staging' }}
21+
ACCT: ${{ inputs.environment == 'production' && '990880627107' || '327995277200' }}
22+
BUCKET: ${{ inputs.environment == 'production' && 'tiny-cloud-antora-docs-release' || 'tiny-cloud-antora-docs-preview' }}
23+
DISTRIBUTION: ${{ inputs.environment == 'production' && 'E3LFU502SQ5UR' || 'E7DUUPEI08HNW'}}
24+
RUN: run-${{ github.run_number }}-${{ github.run_attempt }}
25+
26+
jobs:
27+
build:
28+
name: Build Docs and Deploy
29+
30+
if: github.repository == 'tinymce/tinymce-docs' && github.repository_owner == 'tinymce'
31+
32+
runs-on: ubuntu-latest
33+
34+
defaults:
35+
run:
36+
shell: bash
37+
38+
steps:
39+
- name: Checkout branch
40+
uses: actions/checkout@v5
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v5
44+
with:
45+
cache: 'yarn'
46+
node-version: 24
47+
48+
- name: Install dependencies
49+
run: yarn install
50+
51+
- name: Build Website
52+
run: yarn antora ./antora-playbook.yml
53+
54+
- name: Rename site folder to docs
55+
run: |
56+
mv ./build/site ./build/docs
57+
58+
- name: Rename sitemap.xml to antora-sitemap.xml
59+
run: |
60+
mv ./build/docs/sitemap.xml ./build/docs/antora-sitemap.xml
61+
62+
- name: configure aws credentials
63+
uses: aws-actions/[email protected]
64+
with:
65+
role-to-assume: 'arn:aws:iam::${{ env.ACCT }}:role/${{ env.TARGET }}-tinymce-docs-update'
66+
role-session-name: tinymce-docs-${{ env.TARGET }}-release
67+
aws-region: us-east-1
68+
69+
- name: Upload website preview to S3
70+
run: |
71+
aws s3 sync ./build s3://${BUCKET}/main/${RUN}
72+
73+
- name: Create redirects on S3
74+
uses: tinymce/[email protected]
75+
with:
76+
build: ./build/
77+
redirects: ./redirects.json
78+
bucket: ${{ env.BUCKET }}
79+
prefix: main/${{ env.RUN }}
80+
parallel: 10
81+
82+
- name: Update pointer to current run output
83+
run: |
84+
aws s3api put-object --bucket ${BUCKET} --key main/index.html --body .github/workflows/resources/empty.html --content-type text/html --metadata pointer=${RUN}
85+
86+
- name: Tag old versions for cleanup
87+
uses: tinymce/[email protected]
88+
with:
89+
bucket: ${{ env.BUCKET }}
90+
folder: main
91+
parallel: 20
92+
93+
- name: Invalidate Cloudfront Cache
94+
# sleep to wait for envoy's version pointer caching to expire
95+
run: |
96+
sleep 30s
97+
aws cloudfront create-invalidation --distribution-id ${{ env.DISTRIBUTION }} --paths "/docs/*"

0 commit comments

Comments
 (0)