Skip to content

Commit fc9d578

Browse files
committed
TCLOUD-4780: Add workflows to create and delete previews
1 parent ca22431 commit fc9d578

File tree

4 files changed

+122
-1
lines changed

4 files changed

+122
-1
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Ticket: DOC-<num>
22

3-
Site: [DOC-<num> site](http://docs-<hotfix/feature>-6-doc-<num>.staging.tiny.cloud/docs/tinymce/6/)
3+
Site: [DOC-<num> site](https://pr-<PR#>.tinymce-docs.iad.staging.tiny.cloud/docs/tinymce/6/)
44

55
Changes:
66
* <placeholder-text>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Preview Create/Update
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
10+
11+
# Need ID token write permission to use OIDC
12+
permissions:
13+
id-token: write
14+
15+
env:
16+
PR: pr-${{ github.event.number }}
17+
RUN: run-${{ github.run_number }}-${{ github.run_attempt }}
18+
19+
jobs:
20+
21+
build:
22+
name: Update Docs Preview
23+
24+
runs-on: ubuntu-latest
25+
26+
defaults:
27+
run:
28+
shell: bash
29+
30+
steps:
31+
- name: Checkout branch
32+
uses: actions/checkout@v5
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v5
36+
with:
37+
cache: 'yarn'
38+
node-version: 24
39+
40+
- name: Install dependencies
41+
run: yarn install
42+
43+
- name: Build Website
44+
run: yarn antora ./antora-playbook.yml
45+
46+
- name: Rename site folder to docs
47+
run: |
48+
mv ./build/site ./build/docs
49+
50+
- name: Rename sitemap.xml to antora-sitemap.xml
51+
run: |
52+
mv ./build/docs/sitemap.xml ./build/docs/antora-sitemap.xml
53+
54+
- name: configure aws credentials
55+
uses: aws-actions/[email protected]
56+
with:
57+
role-to-assume: arn:aws:iam::327995277200:role/staging-tinymce-docs-update
58+
role-session-name: tinymce-docs-update
59+
aws-region: us-east-1
60+
61+
- name: Upload website preview to S3
62+
run: |
63+
aws s3 sync ./build s3://tiny-cloud-antora-docs-preview/${PR}/${RUN}
64+
65+
- name: Create redirects on S3
66+
uses: tinymce/[email protected]
67+
with:
68+
build: ./build/
69+
redirects: https://raw.githubusercontent.com/tinymce/tinymce-docs/refs/heads/main/redirects.json
70+
bucket: tiny-cloud-antora-docs-preview
71+
prefix: ${{ env.PR }}/${{ env.RUN }}
72+
parallel: 10
73+
74+
- name: Update pointer to current run output
75+
run: |
76+
aws s3api put-object --bucket tiny-cloud-antora-docs-preview --key ${PR}/index.html --body .github/workflows/resources/empty.html --content-type text/html --metadata pointer=${RUN}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Preview Delete
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
8+
# Need ID token write permission to use OIDC
9+
permissions:
10+
id-token: write
11+
12+
env:
13+
PR: pr-${{ github.event.number }}
14+
15+
jobs:
16+
cleanup:
17+
name: Cleanup Docs Preview
18+
19+
runs-on: ubuntu-latest
20+
21+
defaults:
22+
run:
23+
shell: bash
24+
25+
steps:
26+
- name: Checkout branch
27+
uses: actions/checkout@v5
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v5
31+
with:
32+
cache: 'yarn'
33+
node-version: 24
34+
35+
- name: configure aws credentials
36+
uses: aws-actions/[email protected]
37+
with:
38+
role-to-assume: arn:aws:iam::327995277200:role/staging-tinymce-docs-update
39+
role-session-name: tinymce-docs-delete
40+
aws-region: us-east-2
41+
42+
- name: Remove website preview from S3
43+
run: |
44+
aws s3 rm --recursive s3://tiny-cloud-antora-docs-preview/${PR}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!doctype html><title>?</title>

0 commit comments

Comments
 (0)