Skip to content

Commit dc63ee5

Browse files
fix(ci): check existence of docs dir for docs jobs
Signed-off-by: Cameron Smith <cameron.ray.smith@gmail.com>
1 parent f782a13 commit dc63ee5

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,27 @@ jobs:
7878
dry_run_release: ${{ steps.set-variables.outputs.dry_run_release }}
7979
checkout_ref: ${{ steps.set-variables.outputs.checkout_ref }}
8080
checkout_rev: ${{ steps.set-variables.outputs.checkout_rev }}
81+
has_docs: ${{ steps.check-docs.outputs.has_docs }}
8182

8283
steps:
84+
- name: Checkout for docs check
85+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
86+
with:
87+
sparse-checkout: |
88+
docs
89+
sparse-checkout-cone-mode: false
90+
91+
- name: Check if docs exist
92+
id: check-docs
93+
run: |
94+
if [ -d "docs" ] && [ "$(ls -A docs 2>/dev/null)" ]; then
95+
echo "has_docs=true" >> $GITHUB_OUTPUT
96+
echo "Documentation directory exists and is not empty"
97+
else
98+
echo "has_docs=false" >> $GITHUB_OUTPUT
99+
echo "Documentation directory does not exist or is empty"
100+
fi
101+
83102
- name: Set action variables
84103
id: set-variables
85104
run: |
@@ -127,7 +146,7 @@ jobs:
127146
128147
preview-docs:
129148
needs: set-variables
130-
if: ${{ needs.set-variables.outputs.skip_ci != 'true' && ( contains(github.event.pull_request.labels.*.name, 'docs-preview') || (github.event_name == 'workflow_dispatch' && inputs.run_docs_preview) ) }}
149+
if: ${{ needs.set-variables.outputs.has_docs == 'true' && needs.set-variables.outputs.skip_ci != 'true' && ( contains(github.event.pull_request.labels.*.name, 'docs-preview') || (github.event_name == 'workflow_dispatch' && inputs.run_docs_preview) ) }}
131150
uses: ./.github/workflows/deploy-docs.yaml
132151
permissions:
133152
contents: read
@@ -275,8 +294,8 @@ jobs:
275294
secrets: inherit
276295

277296
deploy-docs:
278-
needs: [test-python, nixci]
279-
if: ${{ github.repository_owner == 'sciexp' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta') }}
297+
needs: [set-variables, test-python, nixci]
298+
if: ${{ needs.set-variables.outputs.has_docs == 'true' && github.repository_owner == 'sciexp' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta') }}
280299
uses: ./.github/workflows/deploy-docs.yaml
281300
permissions:
282301
contents: read

0 commit comments

Comments
 (0)