Merge pull request #37 from input-output-hk/js/revisions #10
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: Documentation | |
on: | |
push: | |
branches: [ "main" ] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
# 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: "pages" | |
cancel-in-progress: false | |
jobs: | |
# Sources | |
# * https://github.com/haskell/actions/tree/v2/setup#model-cabal-workflow-with-caching | |
# * https://haskell-haddock.readthedocs.io/en/latest/multi-components.html | |
# * https://github.com/input-output-hk/ouroboros-consensus/blob/b0a6f9148d3c3783cb9980c756162426f8066471/.github/workflows/ci.yml | |
# * https://github.com/input-output-hk/ouroboros-consensus/blob/4ff9aa5596598bb3681864b830c8a33e294d9bfe/scripts/docs/haddocks.sh | |
build-documentation: | |
name: Build documentation | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
env: | |
ghc: "9.2.8" | |
cabal: "3.10.1.0" | |
os: ubuntu-latest" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Haskell | |
id: setup-haskell | |
uses: haskell/actions/setup@v2 | |
with: | |
ghc-version: ${{ env.ghc }} | |
cabal-version: ${{ env.cabal }} | |
cabal-update: true | |
- name: Configure the build | |
run: | | |
cabal configure --disable-tests --disable-benchmarks --enable-documentation | |
cabal build all --dry-run | |
# The last step generates dist-newstyle/cache/plan.json for the cache key. | |
- name: Cache cabal store | |
uses: actions/cache@v3 | |
env: | |
cache-name: documentation-cabal-store | |
with: | |
path: ${{ steps.setup-haskell.outputs.cabal-store }} | |
key: ${{ runner.os }}-${{ env.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} | |
${{ runner.os }}-${{ env.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}- | |
${{ runner.os }}-${{ env.ghc }}-${{ env.cache-name }}- | |
- name: Build haddocks | |
run: | | |
./scripts/haddocks.sh | |
tar vzcf haddocks.tgz ./docs/haddocks | |
- name: Upload haddocks as an artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: haddocks | |
path: haddocks.tgz | |
retention-days: 1 | |
deploy-documentation: | |
name: Deploy documentation to GitHub Pages | |
needs: build-documentation | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
# https://github.com/actions/deploy-pages | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Download haddocks artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: haddocks | |
- name: Unpack haddocks artifact | |
run: | | |
tar vzxf haddocks.tgz | |
- name: Upload haddocks artifact to pages | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: ./docs/haddocks | |
- name: Deploy to GitHub pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |