Merge pull request #224 from dusty-nv/20241016/research #238
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: ci | |
on: | |
push: | |
branches: | |
- master | |
- main | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.x | |
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
with: | |
key: mkdocs-material-${{ env.cache_id }} | |
path: .cache | |
restore-keys: | | |
mkdocs-material- | |
- name: Install dependencies | |
run: | | |
pip install mkdocs-material | |
pip install mkdocs-redirects | |
pip install beautifulsoup4 | |
pip install lxml | |
- name: Get mkdocs-material version | |
run: | | |
MKDOCS_MATERIAL_VERSION=$(pip show mkdocs-material | grep Version | cut -d ' ' -f 2) | |
echo "MKDOCS_MATERIAL_VERSION=$MKDOCS_MATERIAL_VERSION" >> $GITHUB_ENV | |
- name: Build the MkDocs site | |
run: | | |
mkdocs build | |
# Custom step to modify HTML files | |
- name: Duplicate the generated site dir with postprocessing | |
run: | | |
python ./scripts/duplicate_site_with_postprocess.py ./site ../site_postprocessed | |
- name: Deploy to GitHub Pages | |
run: | | |
# Initialize gh-pages branch if it doesn't exist | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git | |
git fetch origin gh-pages | |
git checkout gh-pages || git checkout --orphan gh-pages | |
ls -lh | |
git status | |
# Copy the site content into the current directory | |
cp -r ../site_postprocessed/* . | |
# Commit and push the changes | |
git add . | |
git commit -m "Deployed ${GITHUB_SHA} with mkdocs-material v${{ env.MKDOCS_MATERIAL_VERSION }} and HTML post-processing" | |
git push origin gh-pages --force |