-
Notifications
You must be signed in to change notification settings - Fork 0
/
orb.yml
211 lines (200 loc) · 7.21 KB
/
orb.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
version: 2.1
description: |
Easily install and use Strawberry Static Site Generator (SSG) (formally known
as Gotham) on CircleCI. Strawberry is an SSG used to build fast, efficient,
and secure websites from Markdown files. Strawberry is a soft fork of Hugo
and is 99% compatible so this orb will work to build, test, and deploy both
Strawberry and Hugo websites.
Built-in testing is done with HTML Proofer. This orb includes an executor but
works with Linux and macOS images.
display:
home_url: "https://www.StrawberrySSG.com"
source_url: "https://github.com/hubci/strawberry-orb"
orbs:
os-detect: circleci/[email protected]
executors:
hubci:
description: "The 'hubci/strawberry' Docker image."
parameters:
tag:
description: "The 'hubci/strawberry' Docker image version tag."
type: string
docker:
- image: hubci/strawberry:<< parameters.tag >>
commands:
install:
description: |
Install Strawberry in a build. Supports Linux and macOS on amd64.
parameters:
version:
description: "The Strawberry version to install. This is a full SemVer version."
type: string
steps:
- os-detect/init
- run:
name: "Install Strawberry"
command: |
case $OSD_FAMILY in
linux)
OS=linux
PKG_EXT=tar.gz
;;
darwin)
OS=macos
PKG_EXT=tar.gz
;;
*)
echo "Unsupported operating system."
exit 1
;;
esac
dlURL=https://github.com/strawberryssg/strawberry-v0/releases/download/v<< parameters.version >>/strawberry-v<< parameters.version >>-${OS}-amd64.${PKG_EXT}
# If the download fails...
if curl --fail -sSL "$dlURL" 2>/dev/null | $SUDO tar -xz -C /usr/local/bin strawberry 2>/dev/null; then
echo "We're good, continue."
else
if [[ ! << parameters.version >> =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Failed to install. The version number '<< parameters.version >>' is not a full valid SemVer version."
else
echo "Please choose a valid version from the Strawberry tags page, without the leading 'v': https://github.com/strawberryssg/strawberry-v0/tags"
echo "The download URL that failed was: ${dlURL}"
fi
exit 1
fi
html-proofer:
description: |
Run HTML Proofer on the generated site for testing. Ruby and the
`html-proofer` gem must already be installed to use.
parameters:
path:
description: "Path to generated files relative to working_directory."
type: string
default: "./public/"
steps:
- run:
name: "Test generated website with HTML Proofer."
command: "htmlproofer << parameters.path >> --allow-hash-href true --disable-external true"
build:
description: Build a static site with Strawberry located at 'source'. The default is '.'.
parameters:
source:
description: "Path to Strawberry root relative to 'working_directory'."
type: string
default: "."
destination:
description: "Path to where Strawberry outputs generated site. Relative to `source`."
type: string
default: "./public/"
extra-flags:
description: "Additional flags to pass when running Strawberry (e.g. -DF)."
type: string
default: ""
hugo-env:
description: "Set the value of HUGO_ENV prior to running Strawberry."
type: string
default: production
steps:
- run:
name: Build with Strawberry
command: HUGO_ENV=<< parameters.hugo-env >> strawberry -v -s << parameters.source >> -d << parameters.destination >> << parameters.extra-flags >>
jobs:
build:
description: "Build a site with Strawberry."
executor:
name: hubci
tag: << parameters.version >>
parameters:
version:
description: "Strawberry version to use. This is a SemVer version without the 'v'."
type: string
source:
description: "Path to Strawberry root relative to working_directory."
type: string
default: "."
destination:
description: "Path to where Strawberry outputs generated site. Relative to `source`."
type: string
default: "./public"
html-proofer:
description: "Whether or not to test the outputted HTML with HTML Proofer."
type: boolean
default: true
hugo-env:
description: "Set the value of HUGO_ENV prior to running Strawberry."
type: string
default: "production"
strawberry-extra-flags:
description: "Additional flags to pass when running Strawberry (e.g. -DF)."
type: string
default: ""
persist-to-workspace:
description: "Whether to persist generated files to a CircleCI Workspace. This uses `parameters.source` as root and 'parameters.destination' as the path."
type: boolean
default: true
steps:
- checkout
- run:
name: "Checkout Submodules if Needed"
# Useful for when the theme is a submodule
command: |
if [ -f ".gitmodules" ]; then
git submodule sync
git submodule update --init --recursive
fi
- build:
source: << parameters.source >>
destination: << parameters.destination >>
extra-flags: << parameters.strawberry-extra-flags >>
- when:
condition: << parameters.html-proofer >>
steps:
- html-proofer:
path: << parameters.source >>/<< parameters.destination >>
- when:
condition: << parameters.persist-to-workspace >>
steps:
- persist_to_workspace:
paths:
- << parameters.destination >>
root: << parameters.source >>
examples:
build-and-deploy:
description: |
"An example of building a Strawberry site, testing with HTML Proofer, and deployng it. Here the Strawberry source is in a subdirectory called 'src'. The deploy job is empty and serves as an example. Instead of the 'ls' command, you'd want to deploy the files using whatever tools you're used to."
usage:
version: 2.1
orbs:
strawberry: hubci/[email protected]
workflows:
main:
jobs:
- strawberry/build:
html-proofer: true
source: src/
version: "0.15"
- deploy:
filters:
branches:
only: trunk
requires:
- strawberry/build
jobs:
deploy:
docker:
- image: cimg/base:2021.04
steps:
- attach_workspace:
at: my-site
- run: ls -lah my-site
build-and-test:
description: "The simplest example of using the Strawberry orb."
usage:
version: 2.1
orbs:
strawberry: hubci/[email protected]
workflows:
main:
jobs:
- strawberry/build:
html-proofer: true
version: "0.15"