chore(deps): update dependency sphinx-ncs-theme to v1 #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Documentation Build | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: | |
- main | |
paths: | |
- '.github/workflows/docs-build-and-publish.yml' | |
- 'docs/**' | |
push: | |
branches: | |
- main | |
jobs: | |
docs-build-and-publish: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y python3 python3-pip | |
- name: Install Python dependencies | |
working-directory: docs | |
run: | | |
python3 -m pip install -r requirements.txt | |
- name: Build documentation | |
working-directory: docs | |
run: | | |
sphinx-build -M html . build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: doc-build | |
if-no-files-found: error | |
retention-days: 2 | |
path: | | |
docs/build/html/ | |
- name: Update gh-pages | |
if: ${{ github.event_name == 'push' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global --add safe.directory "$(pwd)" | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
git fetch origin gh-pages | |
git checkout gh-pages || git checkout -b gh-pages | |
git rebase origin/gh-pages | |
# Update docs | |
rm -rf docs/html | |
cp -r docs/build/html docs/html | |
rm -rf docs/build | |
# Check for changes | |
if git diff --quiet docs/html; then | |
echo "No changes detected in documentation. Exiting gracefully." | |
exit 0 | |
else | |
echo "Changes detected. Creating a new commit." | |
fi | |
# Create commit with doc updates | |
git add docs/html | |
git commit -m "Updating documentation based on ${{ github.sha }}" | |
# Push changes | |
git push origin gh-pages:gh-pages |