Skip to content

Commit

Permalink
Enable GH Pages workflow on pushes to master & mllint-site branches, …
Browse files Browse the repository at this point in the history
…fixes GH Pages website footer so that it can show individual commit versions instead of just proper tags
  • Loading branch information
bvobart committed Jul 27, 2021
1 parent 3b6aa93 commit d133457
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
name: Publish mllint's GitHub Pages website

# Runs on
# - pushes to master with changes to the files in docs/gh-pages or this file
# - release tags
on:
push:
branches:
- master
- mllint-site
paths:
- docs/gh-pages
- .github/workflows/gh-pages.yml
tags:
- "v*"

Expand Down Expand Up @@ -40,13 +49,22 @@ jobs:
- name: Generate Categories & Rules documentation
run: go run ./docs/gh-pages/scripts/generate-docs.go

- name: Build website
- name: Build website (tagged version)
if: startsWith(github.ref, 'refs/tags/v')
working-directory: docs/gh-pages/
run: hugo --minify
env:
HUGO_MLLINT_VERSION: ${GITHUB_REF#refs/tags/v}

- name: Build website (regular commit)
if: startsWith(github.ref, 'refs/heads/')
working-directory: docs/gh-pages/
run: |
echo "HUGO_MLLINT_VERSION=$(git describe --tags)" >> $GITHUB_ENV
hugo --minify
- name: Deploy website
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_dir: ./docs/gh-pages/public/
2 changes: 2 additions & 0 deletions docs/gh-pages/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@

/content/docs/rules/*
!/content/docs/rules/_index.md

/public/
19 changes: 15 additions & 4 deletions docs/gh-pages/layouts/partials/extend_footer.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
<footer class="footer-version">
<!-- HUGO_MLLINT_VERSION will be set to basically the output of `git describe --tags` during build, e.g. `v0.11.0` or `v0.11.0-8-g3b6aa93` -->
{{ $version := getenv "HUGO_MLLINT_VERSION" }}
{{ if ne $version "" }}
<span>mllint version: </span>
<span><a href="https://github.com/bvobart/mllint/releases/tag/{{ $version }}" rel="noopener noreferrer" target="_blank">{{ $version }}</a></span>
{{ $tag := index (split $version "-") 0 }}

<!-- If not set, just say version unknown -->
{{ if eq $version "" }} <span>mllint version unknown</span>
<!-- else, display proper version with link to latest release. -->
{{ else }}
<span>mllint version unknown</span>
<span>mllint version: </span>
<span><a href="https://github.com/bvobart/mllint/releases/tag/{{ $tag }}" rel="noopener noreferrer" target="_blank">{{ $tag }}</a></span>
<!-- if the current deployment is not a tagged release, but a regular commit, display the full Git reference -->
{{ if ne $version $tag }}
<br />
<span> Git ref:</span>
<span> {{ $version }} </span>
{{ end }}
{{ end }}

</footer>

0 comments on commit d133457

Please sign in to comment.