-
Notifications
You must be signed in to change notification settings - Fork 4
94 lines (80 loc) · 3.31 KB
/
gh-pages.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: github pages
on:
pull_request: # preview for PR (deleted on closing the PR)
push:
branches:
- main # main deploy
jobs:
deploy:
runs-on: ubuntu-22.04
env:
PR_PATH: pull/${{github.event.number}}
steps:
- name: Comment on PR
uses: hasura/[email protected]
if: github.ref != 'refs/heads/main'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
number: ${{ github.event.number }}
id: deploy-preview
message: "Starting deployment of preview ⏳..."
- name: Set domain
run: echo "DOMAIN=mevislab.github.io" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
extended: true
- name: Set production base URL
run: echo "BASE_URL=https://${{ env.DOMAIN }}/${{ github.event.repository.name }}/" >> $GITHUB_ENV
- name: Install Dependencies
working-directory: ${{ env.DOMAIN }}
run: npm install
- name: Build main website
if: github.ref == 'refs/heads/main'
working-directory: ${{ env.DOMAIN }}
run: hugo --minify --baseURL "${{ env.BASE_URL }}" -d public
env:
HUGO_ENV: production
- name: Check HTML
uses: chabad360/htmlproofer@v2
with:
directory: "./${{ env.DOMAIN }}/public"
arguments: --only-4xx --assume-extension --empty-alt-ignore
continue-on-error: true
- name: Deploy main branch
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.PUBLISH_TOKEN }}
publish_dir: ./${{ env.DOMAIN }}/public
- name: Set base URL for preview if PR
if: github.ref != 'refs/heads/main'
run: echo "BASE_URL=https://${{ env.DOMAIN }}/${{ github.event.repository.name }}/${{ env.PR_PATH}}/" >> $GITHUB_ENV
- name: Build PR preview website
if: github.ref != 'refs/heads/main'
working-directory: ${{ env.DOMAIN }}
run: hugo --minify --baseURL "${{ env.BASE_URL }}" -d public
env:
HUGO_ENV: staging
- name: Deploy to PR preview
uses: peaceiris/actions-gh-pages@v3
if: github.ref != 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./${{ env.DOMAIN }}/public
destination_dir: ${{ env.PR_PATH }}
- name: Update comment
uses: hasura/[email protected]
if: github.ref != 'refs/heads/main'
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 }}/"