Skip to content

Commit b3947d6

Browse files
authored
Update static.yml
Signed-off-by: Horti <[email protected]>
1 parent a831425 commit b3947d6

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

.github/workflows/static.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Deploy static content to Pages
33

44
on:
55
# Runs on pushes targeting the default branch
6-
push:
7-
branches: ["master"]
6+
pull_request:
7+
branches: [ "master" ]
88

99
# Allows you to run this workflow manually from the Actions tab
1010
workflow_dispatch:
@@ -14,18 +14,17 @@ permissions:
1414
contents: read
1515
pages: write
1616
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+
2019
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
2322

2423
jobs:
2524
# Single deploy job since we're just deploying
2625
deploy:
2726
environment:
28-
name: github-pages
27+
name: pr-preview-${{ github.event.pull_request.number || github.run_id }}
2928
url: ${{ steps.deployment.outputs.page_url }}
3029
runs-on: ubuntu-latest
3130
steps:
@@ -41,12 +40,24 @@ jobs:
4140
- name: Install dependencies
4241
run: make setup
4342
- 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 }}
4544
- name: Upload artifact
4645
uses: actions/upload-pages-artifact@v3
4746
with:
48-
# Upload entire repository
47+
# Upload just the public folder
4948
path: 'public'
5049
- name: Deploy to GitHub Pages
5150
id: deployment
5251
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

Comments
 (0)