Skip to content

Commit 43b24b8

Browse files
authored
feat(docs): templatize home page with build context and date (#459)
Add `CONTEXT` and `DATE` placeholders to public/docs/index.html to match surge preview pattern. Update build-documentation action to accept context_label input and apply sed substitutions. Configure both master and PR workflows to pass appropriate context labels (master branch or PR #number). Also add the `DATE` placeholder in the page used in surge.sh deployment.
1 parent 2abd803 commit 43b24b8

7 files changed

Lines changed: 20 additions & 4 deletions

File tree

.github/actions/build-documentation/action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: 'Build the documentation'
22
description: 'Build static and API documentation.'
33

4+
inputs:
5+
context_label:
6+
description: 'Label describing the build context (e.g., "master branch" or "PR #123")'
7+
required: true
8+
49
runs:
510
using: 'composite'
611
steps:
@@ -18,3 +23,8 @@ runs:
1823
- name: Copy static pages
1924
shell: bash
2025
run: cp -r public/docs build
26+
- name: Apply template placeholders
27+
shell: bash
28+
run: |
29+
sed -i "s/@CONTEXT@/${{ inputs.context_label }}/g" build/docs/index.html
30+
sed -i "s/@DATE@/$(date -u +%Y-%m-%dT%H:%M:%SZ)/g" build/docs/index.html

.github/workflows/deploy-documentation-pr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
- uses: actions/checkout@v6
2121
- name: Build documentation
2222
uses: ./.github/actions/build-documentation
23+
with:
24+
context_label: PR ${{ github.event.pull_request.number }}
2325
- name: Upload
2426
uses: actions/upload-artifact@v7
2527
with:

.github/workflows/deploy-documentation.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
- uses: actions/checkout@v6
2929
- name: Build documentation
3030
uses: ./.github/actions/build-documentation
31+
with:
32+
context_label: master branch
3133
- name: Upload artifact for GitHub Pages
3234
uses: actions/upload-pages-artifact@v4
3335
with:

.github/workflows/surge-pr-fork-01-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
mkdir site
2323
cp -r public/surge/* site/
2424
sed -i "s/@PR_NUMBER@/${PR_NUMBER}/g" site/index.html
25+
sed -i "s/@DATE@/$(date -u +%Y-%m-%dT%H:%M:%SZ)/g" site/index.html
2526
2627
- name: Upload artifact
2728
uses: actions/upload-artifact@v7

.github/workflows/surge-preview-for-pr.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
mkdir site
3737
cp -r public/surge/* site/
3838
sed -i "s/@PR_NUMBER@/${PR_NUMBER}/g" site/index.html
39+
sed -i "s/@DATE@/$(date -u +%Y-%m-%dT%H:%M:%SZ)/g" site/index.html
3940
- name: Publish Demo preview
4041
if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true'
4142
id: publish_demo_preview

public/docs/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<title>Process Analytics Playground site</title>
5+
<title>Process Analytics Playground site (@CONTEXT@)</title>
66
</head>
77
<body>
88
<section>
9-
<h1>Process Analytics Playground site</h1>
9+
<h1>Process Analytics Playground site (@CONTEXT@)</h1>
1010
<p>Have a look at an example of the <a href="api/">documentation of an TypeScript API generated with Typedoc</a></p>
1111
</section>
12-
<footer>Process Analytics - 2021-present</footer>
12+
<footer>Process Analytics - 2021-present (built on @DATE@)</footer>
1313
</body>
1414
</html>

public/surge/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<h1>Process Analytics Playground site for PR @PR_NUMBER@</h1>
1010
<p>This page has been created to test <a href="https://surge.sh/">Surge</a> deployments.</p>
1111
</section>
12-
<footer>Process Analytics - 2021-present</footer>
12+
<footer>Process Analytics - 2021-present (built on @DATE@)</footer>
1313
</body>
1414
</html>

0 commit comments

Comments
 (0)