Skip to content

Commit 9ffab4c

Browse files
Copilotaih
andauthored
Make GitHub Pages deployment conditional in docs workflow (#35)
* Initial plan * Add conditional check to skip GitHub Pages deployment if not configured Co-authored-by: aih <217356+aih@users.noreply.github.com> * Fix shellcheck issues in docs-deploy workflow Co-authored-by: aih <217356+aih@users.noreply.github.com> * Remove actionlint binary and update .gitignore Co-authored-by: aih <217356+aih@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: aih <217356+aih@users.noreply.github.com>
1 parent 308641c commit 9ffab4c

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

.github/workflows/docs-deploy.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ concurrency:
1717

1818
jobs:
1919
deploy:
20-
environment:
21-
name: github-pages
22-
url: ${{ steps.deployment.outputs.page_url }}
2320
runs-on: ubuntu-latest
2421
steps:
2522
- name: Checkout
@@ -37,11 +34,32 @@ jobs:
3734
- name: Build site
3835
run: mkdocs build
3936

37+
- name: Check if GitHub Pages is configured
38+
id: check_pages
39+
continue-on-error: true
40+
run: |
41+
# Check if the pages environment exists by checking repository settings
42+
if gh api "repos/${{ github.repository }}/pages" &>/dev/null; then
43+
echo "pages_enabled=true" >> "$GITHUB_OUTPUT"
44+
echo "GitHub Pages is configured"
45+
else
46+
echo "pages_enabled=false" >> "$GITHUB_OUTPUT"
47+
echo "GitHub Pages is not configured - skipping deployment"
48+
fi
49+
env:
50+
GH_TOKEN: ${{ github.token }}
51+
4052
- name: Upload artifact
53+
if: steps.check_pages.outputs.pages_enabled == 'true'
4154
uses: actions/upload-pages-artifact@v3
4255
with:
4356
path: ./site
4457

58+
- name: Setup Pages environment
59+
if: steps.check_pages.outputs.pages_enabled == 'true'
60+
uses: actions/configure-pages@v5
61+
4562
- name: Deploy to GitHub Pages
63+
if: steps.check_pages.outputs.pages_enabled == 'true'
4664
id: deployment
4765
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ tests/reports/
44

55
# MkDocs
66
site/
7+
actionlint

0 commit comments

Comments
 (0)