Revamp build process #33
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: 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 (admin, standards, 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 standards docs in | |
# parallel. | |
# | |
build-admin: | |
name: Build admin docs | |
needs: build-site | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
depth: 1 | |
- name: Use Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Build site | |
run: | | |
make build-admin | |
- name: Save artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: admin-docs | |
path: _site/administrative | |
build-standards: | |
name: Build standards docs | |
needs: build-site | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
depth: 1 | |
- name: Use Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Build site | |
run: | | |
make build-standards | |
- name: Save artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: standards-docs | |
path: _site/standards | |
build-site: | |
name: Build site | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
depth: 1 | |
- name: Use Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
env: | |
JEKYLL: 1 | |
- name: Build site | |
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-admin, build-standards] | |
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 Standards docs artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: standards-docs | |
path: _site/standards | |
- name: Download Administrative docs artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: 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 |