@@ -3,8 +3,8 @@ name: Deploy static content to Pages
3
3
4
4
on :
5
5
# Runs on pushes targeting the default branch
6
- push :
7
- branches : ["master"]
6
+ pull_request :
7
+ branches : [ "master" ]
8
8
9
9
# Allows you to run this workflow manually from the Actions tab
10
10
workflow_dispatch :
@@ -14,18 +14,17 @@ permissions:
14
14
contents : read
15
15
pages : write
16
16
id-token : write
17
-
18
- # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19
- # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
17
+ pull-requests : write
18
+
20
19
concurrency :
21
- group : " pages"
22
- cancel-in-progress : false
20
+ group : " pages-${{ github.event.pull_request.number || github.run_id }} "
21
+ cancel-in-progress : true
23
22
24
23
jobs :
25
24
# Single deploy job since we're just deploying
26
25
deploy :
27
26
environment :
28
- name : github-pages
27
+ name : pr-preview-${{ github.event.pull_request.number || github.run_id }}
29
28
url : ${{ steps.deployment.outputs.page_url }}
30
29
runs-on : ubuntu-latest
31
30
steps :
@@ -41,12 +40,24 @@ jobs:
41
40
- name : Install dependencies
42
41
run : make setup
43
42
- name : Build Academy
44
- run : make build-preview
43
+ run : make build-preview BASEURL=https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview-${{ github.event.pull_request.number || github.run_id }}
45
44
- name : Upload artifact
46
45
uses : actions/upload-pages-artifact@v3
47
46
with :
48
- # Upload entire repository
47
+ # Upload just the public folder
49
48
path : ' public'
50
49
- name : Deploy to GitHub Pages
51
50
id : deployment
52
51
uses : actions/deploy-pages@v4
52
+ - name : Comment Preview URL on PR
53
+ if : github.event_name == 'pull_request'
54
+ uses : marocchino/sticky-pull-request-comment@v2
55
+ with :
56
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
57
+ message : |
58
+ 🚀 **Preview deployment for PR #${{ github.event.pull_request.number }}**
59
+
60
+ 🌐 PR URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview-${{ github.event.pull_request.number || github.run_id }}
61
+ > 📖 General Preview: ${{ steps.deployment.outputs.page_url }}
62
+
63
+ This preview will be updated automatically when you push new commits to this PR.
0 commit comments