-
-
Notifications
You must be signed in to change notification settings - Fork 8
92 lines (88 loc) · 2.64 KB
/
deploy-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
name: Deploy to GitHub Pages
on:
push:
branches:
- master
tags:
- "*"
pull_request:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-output
path: build/
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
# Only deploy non-tagged builds (otherwise we deploy twice when
# we tag a release).
if: "!startsWith(github.ref, 'refs/tags/')"
permissions:
contents: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-output
path: build/
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/master' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Build output to publish to the `gh-pages` branch:
publish_dir: ./build
user_name: jwalton
user_email: [email protected]
pdf:
name: Generate PDF Version
runs-on: ubuntu-latest
permissions:
contents: write
needs: build
# Generate a new release every time there's a tag.
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-output
path: build/
- name: Install Prince (HTML to PDF converter)
run: |
curl https://www.princexml.com/download/prince-14.2-linux-generic-x86_64.tar.gz -O
tar zxf prince-14.2-linux-generic-x86_64.tar.gz
cd prince-14.2-linux-generic-x86_64
yes "" | sudo ./install.sh
- name: Start Server and Build PDF
run: |
# Symlink to make docusaurus `baseUrl` working
ln -s ./build rust-book-abridged
# Start local server and wait for it to be ready
npx serve . -p 1337 & npx wait-on http://localhost:1337/rust-book-abridged
# Generate PDF
npx docusaurus-prince-pdf -u http://localhost:1337/rust-book-abridged --output rust-book-abridged.pdf
# Kill server
fuser -k 1337/tcp
- uses: ncipollo/release-action@v1
with:
generateReleaseNotes: true
makeLatest: true
artifacts: "rust-book-abridged.pdf"