diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ff28967..cde7e39 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -10,8 +10,26 @@ on: # yamllint disable-line rule:truthy - main jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Build site + run: | + docker run --rm \ + -v "$PWD":/src \ + -w /src \ + hugomods/hugo:reg-0.147.9 hugo + - name: Validate pages + run: | + find content -name '*.md' \ + -exec printf 'Checking %s\n' {} \; \ + -exec ./validate-page.sh {} \; deploy: runs-on: ubuntu-latest + needs: validate steps: # Run Hugo on the server to build the site - name: Build Site with Hugo diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..01f46f7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +--- +name: Validate Site + +on: + pull_request: + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Build site + run: | + docker run --rm \ + -v "$PWD":/src \ + -w /src \ + hugomods/hugo:reg-0.147.9 hugo + - name: Validate pages + run: | + find content -name '*.md' \ + -exec printf 'Checking %s\n' {} \; \ + -exec ./validate-page.sh {} \; diff --git a/.yamllint.yml b/.yamllint.yml index 412e2c4..b1b08b6 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -6,3 +6,4 @@ ignore: | rules: line-length: disable + truthy: disable diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 1241f05..0de28fb 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -43,7 +43,7 @@ {{- end }} {{- with .Site.Params.author.name }} - + {{- end }} {{- partial "seo/main.html" . }} {{- with .Site.Params.favicon }} diff --git a/validate-page.sh b/validate-page.sh index 195ae4e..ac9f898 100755 --- a/validate-page.sh +++ b/validate-page.sh @@ -12,8 +12,11 @@ path=$1 # Collapse multiple slashes to 1 path=$(echo "$path" | sed -E 's#/+#/#g') +# Remove replace _index.md paths with the path that will lead to the index. +if [[ $path == */_index.md ]]; then + path=${path%/_index.md} # Remove .md from paths. -if [[ $path == *.md ]]; then +elif [[ $path == *.md ]]; then path=${path%.md} fi