-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
127 lines (107 loc) · 3.41 KB
/
Taskfile.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
version: "3"
vars:
HUGO_VERSION: "0.134.3"
HUGO_PATH: ".tmp/hugo"
B2_BIN_PATH: "$HOME/bin/b2"
MINIFY_TOOL: "./node_modules/minify/bin/minify.js"
EXTERNAL_ASSETS_PATH: "./assets/external"
tasks:
clean:
desc: Clean build directory
cmds:
- rm -rfv .tmp public/**
npm-install:
desc: Install npm dependencies
cmds:
- npm install
hugo-install:
desc: Install Hugo
cmds:
- task: npm-install
- ./node_modules/hugo-installer/bin/hugo-installer.js --extended true --version {{.HUGO_VERSION}} --destination .tmp/
hugo-build:
desc: Build Hugo site
cmds:
- task: hugo-install
- "{{.HUGO_PATH}}"
install-b2:
desc: Install Backblaze B2 CLI if not already installed
cmds:
- |
if ! command -v b2 &> /dev/null; then
mkdir -p $HOME/bin
curl -L https://github.com/Backblaze/B2_Command_Line_Tool/releases/latest/download/b2-linux -o {{.B2_BIN_PATH}}
chmod +x {{.B2_BIN_PATH}}
{{.B2_BIN_PATH}} version
{{.B2_BIN_PATH}} authorize-account
else
echo "b2 is already installed."
fi
copy-baguettebox:
desc: Copy BaguetteBox assets
cmds:
- mkdir -p {{.EXTERNAL_ASSETS_PATH}}
- cp node_modules/baguettebox.js/dist/baguetteBox.min.* {{.EXTERNAL_ASSETS_PATH}}/
copy-lazyload:
desc: Copy LazyLoad assets
cmds:
- mkdir -p {{.EXTERNAL_ASSETS_PATH}}
- cp node_modules/vanilla-lazyload/dist/lazyload.js {{.EXTERNAL_ASSETS_PATH}}/
copy:
desc: Copy external assets
deps:
- copy-lazyload
- copy-baguettebox
new-gallery:
desc: Create new gallery
cmds:
- hugo new --kind gallery gallery/Street-$(date +%m-%Y)
new-blog:
desc: Create new blog post
cmds:
- hugo new --kind blog blog/$(date +%Y-%m-%d)
get-gallery-images:
desc: Fetch gallery images from B2
cmds:
- ./get_gallery_images.sh "content/gallery/**" "{{.B2_APPLICATION_KEY_ID}}" "{{.B2_APPLICATION_KEY}}"
vars:
B2_APPLICATION_KEY_ID:
sh: "[[ -z $B2_APPLICATION_KEY_ID ]] && op --account pixel-combo.1password.com item get sysbnrxrvnlha5nicpxhpzxkru --fields keyID || echo ${B2_APPLICATION_KEY_ID}"
B2_APPLICATION_KEY:
sh: "[[ -z $B2_APPLICATION_KEY ]] && op --account pixel-combo.1password.com item get sysbnrxrvnlha5nicpxhpzxkru --reveal --fields applicationKey || echo $B2_APPLICATION_KEY"
minify-html:
desc: Minify HTML files
cmds:
- find public -name "*.html" -exec bash -c "{{.MINIFY_TOOL}} {} > {}.min && mv {}.min {}" \;
minify-js:
desc: Minify JS files
cmds:
- find public -name "*.js" -exec bash -c "{{.MINIFY_TOOL}} {} > {}.min && mv {}.min {}" \;
minify-css:
desc: Minify CSS files
cmds:
- find public -name "*.css" -exec bash -c "{{.MINIFY_TOOL}} {} > {}.min && mv {}.min {}" \;
minify:
desc: Minify all assets (HTML, JS, CSS)
deps:
- minify-html
- minify-css
- minify-js
link-checker:
desc: Check for broken links in site
cmds:
- "docker run --init -i --rm -w /input -v $(pwd)/public:/input lycheeverse/lychee -n --exclude 'linkedin*' ."
build:
desc: Build
cmds:
- task: npm-install
- task: copy
- task: hugo-build
- task: link-checker
- task: minify
ci:
desc: Continuous Integration build
cmds:
- task: install-b2
- task: get-gallery-images
- task: build