1+ name : Deploy Website
2+
3+ on :
4+ push :
5+ branches : [ main, master ]
6+ paths :
7+ - ' website/**'
8+ - ' docs/**'
9+ pull_request :
10+ branches : [ main, master ]
11+ paths :
12+ - ' website/**'
13+ - ' docs/**'
14+ workflow_dispatch :
15+
16+ jobs :
17+ build-and-deploy :
18+ name : Build and Deploy Hugo Website
19+ runs-on : ubuntu-latest
20+ environment : production
21+ if : github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
22+
23+ steps :
24+ - name : Checkout repository
25+ uses : actions/checkout@v4
26+ with :
27+ submodules : true
28+ fetch-depth : 0
29+
30+ - name : Setup Hugo
31+ uses : peaceiris/actions-hugo@v2
32+ with :
33+ hugo-version : ' latest'
34+ extended : true
35+
36+ - name : Setup Node.js
37+ uses : actions/setup-node@v4
38+ with :
39+ node-version : ' 18'
40+ cache : ' npm'
41+ cache-dependency-path : ' website/package-lock.json'
42+
43+ - name : Install dependencies
44+ run : |
45+ cd website
46+ npm ci
47+
48+ - name : Build website
49+ run : |
50+ cd website
51+ hugo --minify --gc
52+
53+ - name : Deploy to GitHub Pages
54+ uses : peaceiris/actions-gh-pages@v3
55+ if : github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
56+ with :
57+ github_token : ${{ secrets.GITHUB_TOKEN }}
58+ publish_dir : ./website/public
59+ cname : distributed-gradle-building.com
60+
61+ preview :
62+ name : Deploy Preview
63+ runs-on : ubuntu-latest
64+ if : github.event_name == 'pull_request'
65+
66+ steps :
67+ - name : Checkout repository
68+ uses : actions/checkout@v4
69+ with :
70+ submodules : true
71+ fetch-depth : 0
72+
73+ - name : Setup Hugo
74+ uses : peaceiris/actions-hugo@v2
75+ with :
76+ hugo-version : ' latest'
77+ extended : true
78+
79+ - name : Setup Node.js
80+ uses : actions/setup-node@v4
81+ with :
82+ node-version : ' 18'
83+ cache : ' npm'
84+ cache-dependency-path : ' website/package-lock.json'
85+
86+ - name : Install dependencies
87+ run : |
88+ cd website
89+ npm ci
90+
91+ - name : Build website
92+ run : |
93+ cd website
94+ hugo --minify --gc --baseURL "https://distributed-gradle-building-pr-${{ github.event.number }}.surge.sh"
95+
96+ - name : Deploy to Surge.sh
97+ run : |
98+ cd website/public
99+ npx surge --domain "distributed-gradle-building-pr-${{ github.event.number }}.surge.sh" --token ${{ secrets.SURGE_TOKEN }}
100+
101+ - name : Comment PR with preview URL
102+ uses : actions/github-script@v7
103+ with :
104+ script : |
105+ github.rest.issues.createComment({
106+ issue_number: context.issue.number,
107+ owner: context.repo.owner,
108+ repo: context.repo.repo,
109+ body: '🚀 **Website Preview Ready!**\n\nPreview your changes at: https://distributed-gradle-building-pr-${{ github.event.number }}.surge.sh'
110+ })
0 commit comments