-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (50 loc) · 2.01 KB
/
preview.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Deploy Preview
on:
pull_request:
branches:
- main # or the branch you want to base the preview on
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
PR_PATH: pull/${{github.event.number}}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js 22
uses: actions/setup-node@v3
with:
node-version: '22' # Specify the version of Node.js you need
- name: Run install and export
run: |
npm install
npm run export
- name: Comment on PR
uses: hasura/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
number: ${{ github.event.number }}
id: deploy-preview
message: "Starting deployment of preview ⏳..."
- name: Set base URL for preview if PR
run: echo "BASE_URL=https://wiki.watonomous.ca/${{ github.event.repository.name }}/${{ env.PR_PATH}}/" >> $GITHUB_ENV
- name: Build PR preview website
run: hugo --baseURL "${{ env.BASE_URL }}"
env:
HUGO_ENV: staging
- name: Deploy to PR preview
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
destination_dir: ${{ env.PR_PATH }}
cname: wiki.watonomous.ca
- name: Update comment
uses: hasura/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
number: ${{ github.event.number }}
id: deploy-preview
message: "A preview of ${{ github.event.after }} is uploaded and can be seen here:\n\n ✨ ${{ env.BASE_URL }} ✨\n\nChanges may take a few minutes to propagate. Since this is a preview of production, content with `draft: true` will not be rendered. The source is here: https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/"