Skip to content

Commit 74780ab

Browse files
committed
ci: add basic validation to build
1 parent 0121377 commit 74780ab

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

.github/workflows/deploy.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ on:
88
# Allows you to run this workflow manually from the Actions tab
99
workflow_dispatch:
1010

11-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12-
permissions:
13-
contents: read
14-
pages: write
15-
id-token: write
16-
1711
# Allow one concurrent deployment
1812
concurrency:
1913
group: "pages"
@@ -53,18 +47,27 @@ jobs:
5347
HUGO_ENV: production
5448
run: |
5549
hugo --minify
50+
- name: Validate page build
51+
run: |
52+
bash validate.sh
5653
- name: Upload artifact
5754
uses: actions/upload-pages-artifact@v3
5855
with:
5956
path: ./public
60-
57+
6158
# Deployment job
6259
deploy:
6360
environment:
6461
name: github-pages
6562
url: ${{ steps.deployment.outputs.page_url }}
6663
runs-on: ubuntu-latest
6764
needs: build
65+
66+
permissions: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
67+
contents: read
68+
pages: write
69+
id-token: write
70+
6871
steps:
6972
- name: Deploy to GitHub Pages
7073
id: deployment

Taskfile.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ tasks:
1919
cmds:
2020
- |
2121
{{.HUGO}} --minify {{if .TERMUX}}--noBuildLock{{end}}
22+
23+
validate:
24+
desc: Validates the page build.
25+
deps:
26+
- build
27+
cmds:
28+
- |
29+
bash validate.sh
2230
2331
new-blog:
2432
desc: Creates a new blog post.

fetch-toots.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e
23

34
BASE="assets/toots"
45

validate.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -e
3+
4+
BASE="public"
5+
6+
[ -d "$BASE" ] || (echo "Page build is missing, please create that first through 'task build'" && exit -1)
7+
8+
pushd $BASE
9+
10+
# Validate json files
11+
for json in $(find . -iname "*.json" -type f); do
12+
echo "Validating $json..."
13+
jq . "$json" 1> /dev/null
14+
done
15+
16+
popd

0 commit comments

Comments
 (0)