Skip to content

Commit

Permalink
Separated docs workflow to be a reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gbruer15 committed Sep 4, 2024
1 parent d8de420 commit f2b32be
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
42 changes: 25 additions & 17 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
name: Docs Build
on:
workflow_run:
workflows: [CI Tests]
types: [completed]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.workflow_run.head_branch || github.event.workflow_run.head_commit.id }}
cancel-in-progress: true
workflow_call:
inputs:
target_ref:
required: false
type: string
workflow_dispatch:
inputs:
target_ref:
description: 'Commit or branch to build docs'
default: 'main'
required: false
type: string

jobs:
read-params:
name: Get branch or commit ID
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.step1.outputs.ref }}
target_ref: ${{ env.target_ref }}
steps:
- name: Check stuff
id: step1
run: echo "ref=${{ github.event.workflow_run.head_branch || github.event.workflow_run.head_commit.id }}" >> "$GITHUB_OUTPUT"
- name: Set target ref automatically
if: inputs.target_ref == ''
run: |
echo "target_ref=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV
- name: Read target ref from inputs
if: inputs.target_ref
run: |
echo 'target_ref=${{ inputs.target_ref }}' >> $GITHUB_ENV
echo 'formatter_branch=auto-formatter/${{ inputs.target_ref }}' >> $GITHUB_ENV
docs-build:
name: Build documentation
runs-on: ubuntu-latest
Expand All @@ -28,15 +39,14 @@ jobs:
actions: read
id-token: write
checks: write
if: ${{ github.event.workflow_run.conclusion == 'success' && !cancelled() }}
steps:
- name: Check ref
run: echo "run_ref=${{ needs.read-params.outputs.ref }}" >> $GITHUB_ENV
run: echo "target_ref=${{ needs.read-params.outputs.target_ref }}" >> $GITHUB_ENV
- name: Add GLMakie/XFVB dependencies
run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev
- uses: actions/checkout@v4
with:
ref: ${{ env.run_ref }}
ref: ${{ env.target_ref }}
submodules: recursive
- uses: julia-actions/setup-julia@v2
with:
Expand All @@ -53,8 +63,6 @@ jobs:
with:
pattern: 'coverage-*.info'
path: coverage
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Display structure of downloaded files
run: ls -R
- name: Combine LCOV files and generate coverage html
Expand All @@ -76,7 +84,7 @@ jobs:
path: "./docs/build"
docs-deploy:
name: Deploy documentation
if: needs.read-params.outputs.ref == 'main'
if: needs.read-params.outputs.target_ref == 'main'
needs: [read-params, docs-build]
environment:
name: github-pages
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ concurrency:
cancel-in-progress: true

jobs:
auto-format:
format:
uses: ./.github/workflows/auto-format.yaml
secrets: inherit
docs:
uses: ./.github/workflows/docs.yaml
secrets: inherit

0 comments on commit f2b32be

Please sign in to comment.