Skip to content

Commit

Permalink
ci: only run docs build & publish ci when site files have changed (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
will-break-it authored Jan 20, 2025
1 parent 3682456 commit 45b46e9
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,27 +236,48 @@ jobs:
docs-build:
name: "docs: Build"
runs-on: ubuntu-22.04
outputs:
has_changes: ${{ steps.check_changes.outputs.has_changes }}
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Check for site changes
id: check_changes
run: |
SITE_CHANGES=$(git diff --name-only HEAD^ HEAD -- site/ || true)
if [ -z "$SITE_CHANGES" ]; then
echo "No changes in site directory"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Changes detected in site directory:"
echo "$SITE_CHANGES"
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: 🛠️ Setup Node.js
if: steps.check_changes.outputs.has_changes == 'true'
uses: actions/setup-node@v4
with:
node-version: 20
cache: "yarn"
cache-dependency-path: site/yarn.lock

- name: 📦 Install dependencies
if: steps.check_changes.outputs.has_changes == 'true'
working-directory: site
run: yarn install

- name: 🏗️ Build Docusaurus site
if: steps.check_changes.outputs.has_changes == 'true'
working-directory: site
run: |
yarn build
- name: 🚀 Publish Docusaurus build
if: steps.check_changes.outputs.has_changes == 'true'
uses: actions/upload-artifact@v4
with:
name: docusaurus-build
Expand All @@ -266,7 +287,10 @@ jobs:
docs-publish:
name: "docs: Publish"
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: |
github.event_name == 'push' &&
github.ref == 'refs/heads/main' &&
needs.docs-build.outputs.has_changes == 'true'
runs-on: ubuntu-22.04
needs: docs-build
steps:
Expand Down

0 comments on commit 45b46e9

Please sign in to comment.