-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (76 loc) · 2.48 KB
/
pr-preview.yml
File metadata and controls
91 lines (76 loc) · 2.48 KB
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
name: PR Preview
on:
pull_request:
types: [opened, synchronize, reopened]
env:
BLOG_URL: 'https://pr-${{ github.event.pull_request.number }}.preview.example.com'
BLOG_AUTHOR: ${{ secrets.BLOG_AUTHOR || 'bytenoob' }}
BLOG_EMAIL: ${{ secrets.BLOG_EMAIL || 'blog@example.com' }}
MINIFY_ASSETS: 'false'
jobs:
preview:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Node.js dependencies
run: |
if [ -f package.json ]; then
npm ci
else
npm install -g terser cssnano postcss postcss-cli
fi
- name: Cache Emacs packages
uses: actions/cache@v4
with:
path: |
~/.emacs.d/.local/straight
~/.emacs.d/.local/cache
key: ${{ runner.os }}-emacs-${{ hashFiles('**/packages.el') }}
restore-keys: |
${{ runner.os }}-emacs-
- name: Install Emacs
run: |
sudo apt update
sudo apt-get install -y emacs
- name: Build the site
run: |
chmod +x build.sh
./build.sh
env:
CI: true
GITHUB_WORKSPACE: ${{ github.workspace }}
- name: Generate sitemap
run: |
if [ -f generate-sitemap.sh ]; then
chmod +x generate-sitemap.sh
./generate-sitemap.sh
fi
- name: Upload preview artifact
uses: actions/upload-artifact@v4
with:
name: preview-${{ github.event.pull_request.number }}
path: public
retention-days: 7
- name: Comment PR
uses: actions/github-script@v7
with:
script: |
const artifactUrl = `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}`;
const comment = `## 🔍 Preview Build Complete!
Build #${{ github.run_number }} has finished successfully.
📦 [Download preview artifact](${artifactUrl})
### Build Statistics:
- Total HTML files: \`$(find public -name "*.html" | wc -l)\`
- Build size: \`$(du -sh public | cut -f1)\`
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});