-
Notifications
You must be signed in to change notification settings - Fork 11
60 lines (50 loc) · 1.44 KB
/
main.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
name: Build Docusaurus
on:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Build Docusaurus
id: build
run: |
npm run build 2>&1 | tee build.log
- name: Check for errors in log
id: check_log
run: |
if grep -q "compiled with errors" build.log; then
echo "Errors found in build log"
exit 1
fi
- name: Upload build log if failed
uses: actions/upload-artifact@v2
with:
name: build-log
path: build.log
- name: Post build log to PR if failed
if: failure()
run: |
echo "## :x: Docusaurus Build Failed" > build-summary.md
echo "\n### Build Log" >> build-summary.md
echo '```' >> build-summary.md
cat build.log >> build-summary.md
echo '```' >> build-summary.md
shell: bash
- name: Create comment with build log
if: failure()
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
$(cat build-summary.md)