Skip to content

Commit c0127be

Browse files
committed
TCLOUD-4780: Created workflows for automatic previews
1 parent dea49aa commit c0127be

File tree

3 files changed

+128
-0
lines changed

3 files changed

+128
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Preview Create/Update
2+
3+
on:
4+
create:
5+
branches-ignore:
6+
- 'main'
7+
- 'develop'
8+
- 'tinymce/**'
9+
- 'release/**'
10+
- 'archived/**'
11+
12+
push:
13+
branches-ignore:
14+
- 'main'
15+
- 'develop'
16+
- 'tinymce/**'
17+
- 'release/**'
18+
- 'archived/**'
19+
20+
jobs:
21+
22+
build:
23+
name: Update Docs Preview
24+
25+
runs-on: ubuntu-latest
26+
27+
defaults:
28+
run:
29+
shell: bash
30+
working-directory: ./.github/workflows/scripts
31+
32+
steps:
33+
- name: Checkout branch
34+
uses: actions/checkout@v5
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v5
38+
with:
39+
cache: 'yarn'
40+
node-version: 24
41+
42+
- name: Install dependencies
43+
run: yarn install
44+
45+
- name: Build Website
46+
run: yarn antora ./antora-playbook.yml
47+
48+
- name: Rename sitemap.xml
49+
run: |
50+
mv ./build/site/sitemap.xml ./build/site/antora-sitemap.xml
51+
52+
- name: Convert branch into subdomain
53+
id: get-subdomain
54+
run: |
55+
node ./branch-to-subdomain.js | { read s; echo "subdomain=$s" } >> $GITHUB_OUTPUT
56+
57+
- name: configure aws credentials
58+
uses: aws-actions/[email protected]
59+
with:
60+
role-to-assume: arn:aws:iam::327995277200:role/staging-docs-preview-update
61+
role-session-name: docs-preview-update
62+
aws-region: us-east-2
63+
64+
- name: Upload website preview to S3
65+
run: |
66+
aws s3 sync --delete ./build/site s3://tiny-cloud-antora-docs-preview/${SUBDOMAIN}/docs
67+
env:
68+
SUBDOMAIN: ${{ steps.get-subdomain.outputs.subdomain }}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Preview Delete
2+
3+
on:
4+
delete:
5+
branches-ignore:
6+
- 'main'
7+
- 'develop'
8+
- 'tinymce/**'
9+
- 'release/**'
10+
- 'archived/**'
11+
12+
jobs:
13+
cleanup:
14+
name: Cleanup Docs Preview
15+
16+
runs-on: ubuntu-latest
17+
18+
defaults:
19+
run:
20+
shell: bash
21+
working-directory: ./.github/workflows/scripts
22+
23+
steps:
24+
- name: Checkout branch
25+
uses: actions/checkout@v5
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v5
29+
with:
30+
cache: 'yarn'
31+
node-version: 24
32+
33+
- name: Convert branch into subdomain
34+
id: get-subdomain
35+
run: |
36+
node ./branch-to-subdomain.js | { read s; echo "subdomain=$s" } >> $GITHUB_OUTPUT
37+
38+
- name: configure aws credentials
39+
uses: aws-actions/[email protected]
40+
with:
41+
role-to-assume: arn:aws:iam::327995277200:role/staging-docs-preview-update
42+
role-session-name: docs-preview-delete
43+
aws-region: us-east-2
44+
45+
- name: Remove website preview from S3
46+
run: |
47+
aws s3 rm s3://tiny-cloud-antora-docs-preview/${SUBDOMAIN}/docs
48+
env:
49+
SUBDOMAIN: ${{ steps.get-subdomain.outputs.subdomain }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
const branch = process.argv[2] ?? process.env.GITHUB_REF_NAME;
3+
const subdomain = (
4+
branch
5+
.toLowerCase() // convert to lowercase
6+
.replace(/[/\s]/g, '-') // convert spaces and slashes to dash
7+
.replace(/[^0-9a-z-]/g, '') // remove non alphanumeric+dash
8+
.replace(/-$/g, '') // remove trailing dash
9+
.slice(0, 63) // limit to 63 characters
10+
);
11+
console.log(subdomain);

0 commit comments

Comments
 (0)