Skip to content

Commit

Permalink
chore: make docs only redeploy if relevant files were changed
Browse files Browse the repository at this point in the history
  • Loading branch information
MoritzLaurer committed Oct 29, 2024
1 parent e36cfd7 commit b7a1b50
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,52 @@ on:
push:
branches:
- main
paths:
- 'docs/**' # Documentation content
- 'mkdocs.yml' # MkDocs configuration
- '.github/workflows/docs.yml' # This workflow file
- 'pyproject.toml' # For doc dependencies
# Add any Python files that generate docs
- 'hf_hub_prompts/**/*.py' # Source files (for docstrings)

# Optional: Allow manual triggers
workflow_dispatch:

permissions:
contents: write

jobs:
check_changes:
runs-on: ubuntu-latest
outputs:
should_deploy: ${{ steps.check.outputs.should_deploy }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for checking changes

- name: Check for documentation changes
id: check
run: |
# Check if this is a manual trigger
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "should_deploy=true" >> $GITHUB_OUTPUT
exit 0
fi
# Check for changes in relevant files
git diff --name-only ${{ github.event.before }} ${{ github.event.after }} > changed_files.txt
# Look for changes in docs, mkdocs.yml, or Python files
if grep -q -E '^docs/|^mkdocs.yml|\.py$' changed_files.txt; then
echo "should_deploy=true" >> $GITHUB_OUTPUT
else
echo "should_deploy=false" >> $GITHUB_OUTPUT
fi
deploy:
needs: check_changes
if: needs.check_changes.outputs.should_deploy == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down

0 comments on commit b7a1b50

Please sign in to comment.