Skip to content

Revamp build process #39

Revamp build process

Revamp build process #39

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-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/metacacher 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-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/metacacher 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/metacacher 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-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: Debug
run: |
ls -l
ls -l _site || :
ls -l _site/administrative || :
ls -l _site/standards || :
- 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: admin-docs
path: _site/administrative
- name: Debug
run: |
ls -l
ls -l _site || :
ls -l _site/administrative || :
ls -l _site/standards || :
- 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