Skip to content

Commit 7c27200

Browse files
committed
Add preview PR deployments
Signed-off-by: Nelo-T. Wallus <[email protected]> Signed-off-by: Nelo-T. Wallus <[email protected]>
1 parent 4f06556 commit 7c27200

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

.github/workflows/pages.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,29 @@ on:
77
pull_request:
88
branches:
99
- main
10+
types:
11+
- opened
12+
- reopened
13+
- synchronize
14+
- closed
1015
workflow_dispatch:
1116

1217
permissions:
1318
contents: read
1419

20+
env:
21+
PAGES_BASE: ${{ github.event_name == 'pull_request' && format('/pages-preview-{0}', github.event.pull_request.number) || '/' }}
22+
1523
concurrency:
16-
group: pages
24+
# set separate concurrency groups for main and PR branches
25+
group: ${{ github.event_name == 'pull_request' && format('pages-preview-{0}', github.event.pull_request.number) || 'pages-main' }}
1726
cancel-in-progress: false
1827

1928
jobs:
2029
build:
2130
runs-on: ubuntu-latest
31+
# only build on main or if the PR is open
32+
if: github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.action != 'closed')
2233
steps:
2334
- uses: actions/checkout@v5
2435
with:
@@ -35,16 +46,20 @@ jobs:
3546
path: .vitepress/dist
3647

3748
deploy:
38-
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
3949
permissions:
4050
pages: write
4151
id-token: write
4252
environment:
4353
name: github-pages
44-
url: ${{ steps.deployment.outputs.page_url }}
54+
url: ${{ steps.deployment.outputs.page_url }} + ${{ env.PAGES_BASE }}
4555
needs: build
4656
runs-on: ubuntu-latest
4757
name: deploy
4858
steps:
4959
- id: deployment
5060
uses: actions/deploy-pages@v4
61+
- uses: thollander/actions-comment-pull-request@v3
62+
if: github.event_name == 'pull_request'
63+
with:
64+
message: |
65+
A preview has been deployed to ${{ steps.deployment.outputs.page_url }} + ${{ env.PAGES_BASE }}

.vitepress/config.mts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { fileURLToPath, URL } from 'node:url'
55
export default withMermaid({
66
title: "Platform Mesh",
77

8+
base: process.env.PAGES_BASE ? process.env.PAGES_BASE : '/',
89

910
description: "Platform Mesh - Building upon the Kubernetes API & Resource Model",
1011

@@ -41,7 +42,6 @@ export default withMermaid({
4142
width: 24,
4243
height: 24
4344
},
44-
4545

4646
outline: [2, 3, 4, 5],
4747

@@ -63,7 +63,7 @@ export default withMermaid({
6363
]
6464
}
6565
],
66-
66+
6767
'/scenarios': {
6868
test: 'Scenarios',
6969
items: [
@@ -72,13 +72,11 @@ export default withMermaid({
7272
],
7373
},
7474

75-
7675
},
77-
7876

7977
socialLinks: [
8078
{ icon: 'github', link: 'https://github.com/platform-mesh' }
8179
]
8280
},
83-
81+
8482
})

0 commit comments

Comments
 (0)