forked from ProjectPythia/cookbook-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (74 loc) · 2.55 KB
/
Copy pathdeploy-book.yaml
File metadata and controls
80 lines (74 loc) · 2.55 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
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
cname:
description: 'Custom domain name'
required: false
default: 'None' # This is just a flag for whether to ignore this input
type: string
jobs:
deploy:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Download merged artifact
if: inputs.is_preview != 'true'
uses: actions/download-artifact@v3
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@v2.24.2
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: peaceiris/actions-gh-pages@v3.9.0
if: |
(github.ref == 'refs/heads/main'
&& inputs.cname == 'None')
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/html
enable_jekyll: false
keep_files: true # This preserves existing previews from open PRs
destination_dir: ${{ inputs.destination_dir }}
- name: Deploy to GitHub Pages with custom domain
uses: peaceiris/actions-gh-pages@v3.9.0
if: |
(github.ref == 'refs/heads/main'
&& inputs.cname != 'None')
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/html
enable_jekyll: false
keep_files: true # This preserves existing previews from open PRs
destination_dir: ${{ inputs.destination_dir }}
cname: ${{ inputs.cname }}