Haddock to Github pages #19
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: Haddock to Github pages | |
on: | |
workflow_run: | |
workflows: | |
- Haskell Nightly CI | |
branches: | |
- dev | |
- develop | |
- master | |
types: | |
- completed | |
permissions: read-all | |
jobs: | |
check: | |
if: ${{ github.ref_name == github.event.repository.default_branch }} | |
runs-on: ubuntu-latest | |
outputs: | |
has-changes: ${{ steps.new-commits.outputs.has-new-commits }} | |
steps: | |
- name: Check for new commits today | |
id: new-commits | |
uses: adriangl/check-new-commits-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
seconds: 90000 # One day plus one hour in seconds | |
haddock: | |
needs: check | |
if: needs.check.outputs.has-changes == 'true' | |
permissions: | |
contents: read | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
include: | |
- os: ubuntu-latest | |
apt-get: graphviz texlive-base texlive-latex-base | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 30 | |
steps: | |
- name: Install ${{ matrix.os }} Packages | |
uses: delgurth/get-package@v6 | |
with: | |
apt-get: ${{ matrix.apt-get }} | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.workflow_run.head_sha }} | |
- name: Restore Stack on Unix | |
id: cache-stack-unix-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: ~/.stack | |
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack-apps.yaml') }}-${{ hashFiles('package.yaml') }} | |
fail-on-cache-miss: true | |
- name: Restore .stack-work | |
id: cache-stack-work-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: .stack-work | |
key: ${{ runner.os }}-stack-work-${{ hashFiles('stack-apps.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }} | |
fail-on-cache-miss: true | |
- name: Setup stack | |
uses: haskell-actions/setup@v2 | |
with: | |
enable-stack: true | |
stack-no-global: true | |
- name: Build Haddock | |
id: haddock | |
run: | | |
stack test --stack-yaml=stack-apps.yaml --haddock --no-haddock-deps \ | |
--haddock-arguments "--hyperlinked-source --quickjump" \ | |
--coverage --no-run-tests | |
echo "doc_path=$(stack path --stack-yaml=stack-apps.yaml --no-haddock-deps --local-doc-root)" \ | |
>> "${GITHUB_OUTPUT}" | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
name: github-pages | |
path: ${{steps.haddock.outputs.doc_path}} | |
retention-days: 1 | |
deploy: | |
needs: haddock | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} |