-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
106 lines (91 loc) · 3.08 KB
/
action.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Pandoc Specification Builder
description: Sets up Pandoc and runs either a pre-defined pandoc-spec script in package.json or the pandoc-spec shell script.
inputs:
include-repository:
description: If true, includes node setup, repository checkout, and npm install. Default is false.
required: false
node-version:
description: Version of node to be installed; ignored if include-repository is false. Default is environment-defined.
required: false
include-pages:
description: If true, includes publication to GitHub Pages. Default is false.
required: false
pages-path:
description: Path of the output directory containing the GitHub Pages content; ignored if include-pages is false. Default is "_site/".
required: false
# Default must match default for path in actions/upload-pages-artifact.
default: "_site/"
runs:
using: composite
steps:
- name: Setup node
if: inputs.include-repository == 'true'
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
registry-url: https://registry.npmjs.org/
- name: Checkout
if: inputs.include-repository == 'true'
uses: actions/checkout@v4
- name: NPM install
if: inputs.include-repository == 'true'
shell: bash
run: |
npm install
- name: Setup Pandoc
uses: pandoc/actions/setup@v1
- name: Build specification
shell: bash
run: |
# Exit codes are handled by script.
set +e
if [[ -f package.json ]]
then
NPM_SCRIPTS=$(npm run)
if [[ $? -eq 0 ]]
then
if [[ "$NPM_SCRIPTS" == "" ]]
then
echo "No scripts found."
GREP_RESULT=1
else
echo "$NPM_SCRIPTS"
# Check for package-defined build.
echo "$NPM_SCRIPTS" | grep -q "^ pandoc-spec-action$"
GREP_RESULT=$?
fi
else
# npm command failed.
exit $?
fi
else
# No package.json.
GREP_RESULT=1
fi
if [[ -f $PWD/node_modules/.bin/pandoc-spec ]]
then
# Update path to include npm binary directory.
PATH=$PATH:$PWD/node_modules/.bin
else
# Pandoc Specification Builder not installed in npm package; install globally.
npm install @legreq/pandoc-spec --global
fi
if [[ $GREP_RESULT -eq 0 ]]
then
echo "Running pandoc-spec-action npm script"
npm run pandoc-spec-action
else
echo "Running pandoc-spec shell script"
pandoc-spec
fi
- name: Configure GitHub Pages
if: inputs.include-pages == 'true'
uses: actions/configure-pages@v5
- name: Upload pages directory
if: inputs.include-pages == 'true'
uses: actions/upload-pages-artifact@v3
with:
path: ${{ inputs.pages-path }}
- name: Deploy to GitHub Pages
if: inputs.include-pages == 'true'
uses: actions/deploy-pages@v4