Custom Github pages post-processing #224
  
    
      This file contains hidden or 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: Custom Github pages post-processing | |
| on: | |
| workflow_dispatch: | |
| workflow_call: | |
| push: | |
| tags: | |
| - "*" | |
| schedule: | |
| - cron: "* 3 * * 5" | |
| env: | |
| MAIN_PYTHON_VERSION: '3.13' | |
| jobs: | |
| update-gh-pages: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ env.MAIN_PYTHON_VERSION }} | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install requests | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Copy tools folder to /tmp and run sitemap script | |
| working-directory: /tmp | |
| run: | | |
| cp -r /home/runner/work/pyansys/pyansys/tools/ . | |
| python ./tools/catsitemap.py | |
| - name: Checkout repository gh-pages branch | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: gh-pages | |
| - name: Replace 'version/stable' with 'version/dev' in index.html | |
| run: | | |
| # Replace landing page with the dev version | |
| cp version/dev/index.html index.html | |
| sed -i 's/href="\([^:"]*\)"/href="version\/dev\/\1"/g' index.html | |
| sed -i 's/src="\([^:"]*\)"/src="version\/dev\/\1"/g' index.html | |
| sed -i 's/action="search.html"/action="version\/dev\/\search.html"/g' index.html | |
| sed -i 's|<html lang="en" data-content_root="./" >|<html lang="en" data-content_root="./version/dev/" >|g' index.html | |
| sed -i '/const ADVANCE_SEARCH_PATH = "search.html";/s|search.html|version/dev/search.html|' index.html | |
| # Update JS variables pointing to static values | |
| sed -i 's|const SEARCH_FILE = ".*_static/search.json";|const SEARCH_FILE = "version/dev/_static/search.json";|g' index.html | |
| sed -i 's|const PROJECTS_FILE = "_static/projects.json"|const PROJECTS_FILE = "version/dev/_static/projects.json"|' index.html | |
| # Replace "version/stable" with "version/dev" in the sitemap.xml | |
| sed -i 's/version\/stable/version\/dev/g' sitemap.xml | |
| - name: Move sitemaps/ to gh-pages root | |
| run: | | |
| rm -rf sitemaps/ && mv /tmp/sitemaps/ . | |
| - name: "Commit changes" | |
| uses: EndBug/add-and-commit@v9 | |
| with: | |
| default_author: github_actions | |
| message: "update index.html and sitemaps folder" |