-
Notifications
You must be signed in to change notification settings - Fork 7
69 lines (63 loc) · 2.05 KB
/
deploy-book.yaml
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
name: deploy-book
on:
workflow_call:
inputs:
artifact_name:
description: 'Name of the artifact (zipped book) created by previous build step'
required: false
default: book-zip
type: string
destination_dir:
description: 'Path to publish to on GitHub Pages, relative to site root. We use this to deploy previews in a subdirectory.'
required: false
default: ''
type: string
is_preview:
description: 'Are we deploying a preview?'
required: false
default: 'false'
type: string
publish_dir:
description: 'Publish dir for the action'
required: false
default: '_build/html'
type: string
jobs:
deploy:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- name: Download merged artifact
if: inputs.is_preview != 'true'
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact_name }}
# For the preview, the official download-artifact action doesn't work
# because the artifact is created by a different workflow
- name: Download preview artifact
if: inputs.is_preview == 'true'
uses: dawidd6/action-download-artifact@v8
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-book.yaml
run_id: ${{ github.event.workflow_run.id }}
name: ${{ inputs.artifact_name }}
- name: Unzip the book
run: |
rm -rf _build/html
unzip book.zip
rm -f book.zip
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
if: |
(github.ref == 'refs/heads/main')
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: ${{ inputs.publish_dir }}
clean: true
clean-exclude: _preview/* # keep existing previews from other PRs
target-folder: ${{ inputs.destination_dir }}