Skip to content

Revamp build process #42

Revamp build process

Revamp build process #42

Workflow file for this run

name: build_deploy
on:
push:
branches: master
pull_request:
repository_dispatch:
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
#
# For each document category (administrative, standard, etc.),
# build using `metanorma site generate`.
#
# At the very end, integrate them all with Jekyll.
#
# NOTE: Try to parallelize the build process as much as possible.
# This is currently done by building the admin and standard docs in
# parallel.
#
build-pending-publication:
name: Build pending-publication docs
needs: build-site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 1
- name: Calculate cache key
id: cache-key
run: |
echo "cache-key=$(scripts/metacachekey metanorma metanorma-pending-publication.yml)" >> $GITHUB_OUTPUT
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
path: _site/pending-publication
key: ${{ steps.cache-key.outputs.cache-key }}
- name: Use Ruby
if: steps.cache.outputs.cache-hit != 'true'
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Build site
if: steps.cache.outputs.cache-hit != 'true'
run: |
make build-pending-publication
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: pending-publication-docs
path: _site/pending-publication
build-public-review:
name: Build public-review docs
needs: build-site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 1
- name: Calculate cache key
id: cache-key
run: |
echo "cache-key=$(scripts/metacachekey metanorma metanorma-public-review.yml)" >> $GITHUB_OUTPUT
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
path: _site/public-review
key: ${{ steps.cache-key.outputs.cache-key }}
- name: Use Ruby
if: steps.cache.outputs.cache-hit != 'true'
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Build site
if: steps.cache.outputs.cache-hit != 'true'
run: |
make build-public-review
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: public-review-docs
path: _site/public-review
build-administrative:
name: Build administrative docs
needs: build-site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 1
- name: Calculate cache key
id: cache-key
run: |
echo "cache-key=$(scripts/metacachekey metanorma metanorma-administrative.yml)" >> $GITHUB_OUTPUT
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
path: _site/administrative
key: ${{ steps.cache-key.outputs.cache-key }}
- name: Use Ruby
if: steps.cache.outputs.cache-hit != 'true'
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Build site
if: steps.cache.outputs.cache-hit != 'true'
run: |
make build-administrative
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: administrative-docs
path: _site/administrative
build-specification:
name: Build specification docs
needs: build-site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 1
- name: Calculate cache key
id: cache-key
run: |
echo "cache-key=$(scripts/metacachekey metanorma metanorma-specification.yml)" >> $GITHUB_OUTPUT
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
# 'specifications' instead of 'specification' to match link in index.adoc
path: _site/specifications
key: ${{ steps.cache-key.outputs.cache-key }}
- name: Use Ruby
if: steps.cache.outputs.cache-hit != 'true'
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Build site
if: steps.cache.outputs.cache-hit != 'true'
run: |
make build-specification
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: specification-docs
# 'specifications' instead of 'specification' to match link in index.adoc
path: _site/specifications
build-report:
name: Build report docs
needs: build-site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 1
- name: Calculate cache key
id: cache-key
run: |
echo "cache-key=$(scripts/metacachekey metanorma metanorma-report.yml)" >> $GITHUB_OUTPUT
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
# 'reports' instead of 'report' to match link in index.adoc
path: _site/reports
key: ${{ steps.cache-key.outputs.cache-key }}
- name: Use Ruby
if: steps.cache.outputs.cache-hit != 'true'
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Build site
if: steps.cache.outputs.cache-hit != 'true'
run: |
make build-report
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: report-docs
# 'reports' instead of 'report' to match link in index.adoc
path: _site/reports
build-directive:
name: Build directive docs
needs: build-site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 1
- name: Calculate cache key
id: cache-key
run: |
echo "cache-key=$(scripts/metacachekey metanorma metanorma-directive.yml)" >> $GITHUB_OUTPUT
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
# 'directives' instead of 'directive' to match link in index.adoc
path: _site/directives
key: ${{ steps.cache-key.outputs.cache-key }}
- name: Use Ruby
if: steps.cache.outputs.cache-hit != 'true'
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Build site
if: steps.cache.outputs.cache-hit != 'true'
run: |
make build-directive
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: directive-docs
# 'directives' instead of 'directive' to match link in index.adoc
path: _site/directives
build-standard:
name: Build standard docs
needs: build-site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 1
- name: Calculate cache key
id: cache-key
run: |
echo "cache-key=$(scripts/metacachekey metanorma metanorma-standard.yml)" >> $GITHUB_OUTPUT
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
# 'standards' instead of 'standard' to match link in index.adoc
path: _site/standards
key: ${{ steps.cache-key.outputs.cache-key }}
- name: Use Ruby
if: steps.cache.outputs.cache-hit != 'true'
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Build site
if: steps.cache.outputs.cache-hit != 'true'
run: |
make build-standard
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: standard-docs
# 'standards' instead of 'standard' to match link in index.adoc
path: _site/standards
build-site:
name: Build site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 1
- name: Calculate cache key
id: cache-key
run: |
echo "cache-key=$(scripts/metacachekey jekyll _config.yml)" >> $GITHUB_OUTPUT
- name: Restore cache
id: cache
uses: actions/cache@v4
with:
path: _site
key: ${{ steps.cache-key.outputs.cache-key }}
- name: Use Ruby
if: steps.cache.outputs.cache-hit != 'true'
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
env:
JEKYLL: 1
- name: Build site
if: steps.cache.outputs.cache-hit != 'true'
run: |
make _site
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: jekyll-site
path: _site
upload-artifact:
name: Upload pages artifact
needs:
- build-site
- build-administrative
- build-directive
- build-pending-publication
- build-public-review
- build-report
- build-specification
- build-standard
runs-on: ubuntu-latest
steps:
# NOTE: Order is important.
# Downloading _site/ first ensures metanorma-generated docs are not
# overwritten.
- name: Download Jekyll artifacts
uses: actions/download-artifact@v4
with:
name: jekyll-site
path: _site
- name: Download Directive docs artifacts
uses: actions/download-artifact@v4
with:
name: directive-docs
# 'directives' instead of 'directive' to match link in index.adoc
path: _site/directives
- name: Download Report docs artifacts
uses: actions/download-artifact@v4
with:
name: report-docs
# 'reports' instead of 'report' to match link in index.adoc
path: _site/reports
- name: Download Specification docs artifacts
uses: actions/download-artifact@v4
with:
name: specification-docs
# 'specifications' instead of 'specification' to match link in index.adoc
path: _site/specifications
- name: Download Public Review docs artifacts
uses: actions/download-artifact@v4
with:
name: public-review-docs
path: _site/public-review
- name: Download Pending Publication docs artifacts
uses: actions/download-artifact@v4
with:
name: pending-publication-doc
path: _site/pending-publication
- name: Download Standard docs artifacts
uses: actions/download-artifact@v4
with:
name: standard-docs
# 'standards' instead of 'standard' to match link in index.adoc
path: _site/standards
- name: Download Administrative docs artifacts
uses: actions/download-artifact@v4
with:
name: administrative-docs
path: _site/administrative
- name: Upload artifact
# Automatically uploads an artifact from the './_site' directory by default
uses: actions/upload-pages-artifact@v3
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
# needs: [build-admin, build-standards]
needs: upload-artifact
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4