Build experimental branches with prefix for public review #60
This file contains 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: Pages | |
on: | |
push: | |
branches: | |
- main | |
pull_request: {} | |
workflow_dispatch: | |
inputs: | |
revisions: | |
description: 'Override the computed list of tags and branches with a space-separated list of tags and branches, in order from first to last.' | |
required: false | |
prefix: | |
description: 'Provide a prefix for experimental branches that need to be published alongside tags. It is ignored if revisions is overriden.' | |
required: false | |
type: string | |
jobs: | |
deploy: | |
env: | |
REVISIONS: ${{ github.event.inputs.revisions != '' && github.event.inputs.revisions || format('{0}', 'unset') }} | |
# the default of is set below so it continue to work whether or not it is an interactive workflow dispatch or not. | |
PROTOTYPE_BRANCHES_PREFIX: ${{ github.event.inputs.prefix != '' && github.event.inputs.prefix || format('{0}', 'prototype') }} | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: "temurin" | |
java-version: "17" | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: "0.118.2" | |
extended: true | |
- name: Setup swap space | |
# The Hugo build can require a significant amount of memory | |
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c | |
with: | |
swap-size-gb: 10 | |
- name: Get the list of tagged revisions (for cache) | |
id: get-revisions | |
run: | | |
echo revisions_hash=$(cd support/OSCAL; git tag | grep -E '^v\d+\.\d+\.\d+$' | sha256sum) >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Cache generated content for existing tags | |
uses: actions/cache@v3 | |
with: | |
# explicitly do not cache develop as they are likely to change | |
path: | | |
site/content/models/v*/ | |
site/data/models/v*/ | |
key: ${{ hashFiles('site/archetypes/**') }}-${{ hashFiles('support/*.sh') }}-${{ steps.get-revisions.outputs.revisions_hash }} | |
# A new tagged revision will invalidate the primary cache key | |
# See https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache | |
restore-keys: | | |
${{ hashFiles('site/archetypes/**') }}-${{ hashFiles('support/*.sh') }} | |
- name: Build | |
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources | |
# GHA runners have 2 CPUs | |
if: env.REVISIONS == 'unset' | |
run: make site -j2 PROTOTYPE_BRANCHES_PREFIX="${{ env.PROTOTYPE_BRANCHES_PREFIX }}" | |
- name: Build (revisions overriden) | |
# override revisions and prototype branch prefix ignored | |
if: env.REVISIONS != 'unset' | |
run: make site -j2 REVISIONS="${{ env.REVISIONS }}" | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 | |
if: github.ref == 'refs/heads/main' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# personal_token: ${{ secrets.COMMIT_TOKEN }} | |
enable_jekyll: false | |
publish_dir: ./site/public | |
publish_branch: nist-pages | |
user_name: OSCAL GitHub Actions Bot | |
user_email: [email protected] | |
commit_message: Deploying website [ci deploy] |