Prevent branches from clobbering each other #219
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Hugo site to Pages | |
on: | |
push: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages-${{ github.ref_name }}" | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Hugo Version | |
id: hugo_version | |
run: | | |
HUGO_VERSION=$(cat .tool-versions | grep hugo | cut -d' ' -f2 | cut -d'_' -f2) | |
echo "HUGO_VERSION=$HUGO_VERSION" >> "$GITHUB_ENV" | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v3 | |
with: | |
hugo-version: ${{ env.HUGO_VERSION }} | |
extended: true | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "22" | |
cache: "npm" | |
# The action defaults to search for the dependency file (package-lock.json, | |
# npm-shrinkwrap.json or yarn.lock) in the repository root, and uses its | |
# hash as a part of the cache key. | |
# https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data | |
cache-dependency-path: "**/package-lock.json" | |
- name: Build | |
run: make -C community.hachyderm.io hugo | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
with: | |
path: community.hachyderm.io/public/ | |
# Only run deploy on main branch, all others just run the build as a CI step. | |
deploy: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |