docs(dataset): sync documentation from dataset@70cc47c17e406f01e3def6… #41
Workflow file for this run
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: Deploy MkDocs Page with Mike | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| - "v*.*.*.doc.*" | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version tag to deploy (e.g., v1.2.0.doc.1)" | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: https://open-ev-data.github.io | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.version || github.ref }} | |
| fetch-depth: 0 | |
| - name: Configure Git Credentials | |
| run: | | |
| git config user.name github-actions[bot] | |
| git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| - name: Fetch gh-pages Branch | |
| run: | | |
| git fetch origin gh-pages --depth=1 || echo "gh-pages branch does not exist yet" | |
| git branch gh-pages origin/gh-pages 2>/dev/null || echo "Creating new gh-pages branch" | |
| - name: Install Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install Poetry | |
| run: pip install poetry | |
| - name: Install Dependencies | |
| run: poetry install --no-root | |
| - name: Extract Version | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| TAG="${{ inputs.version }}" | |
| else | |
| TAG=${GITHUB_REF##*/} | |
| fi | |
| if [[ $TAG =~ ^v([0-9]+\.[0-9]+)\.[0-9]+\.doc\.[0-9]+$ ]]; then | |
| VERSION="${BASH_REMATCH[1]}.x" | |
| elif [[ $TAG =~ ^v([0-9]+\.[0-9]+)\.[0-9]+$ ]]; then | |
| VERSION="${BASH_REMATCH[1]}.x" | |
| else | |
| echo "Error: Tag format not recognized: $TAG" | |
| exit 1 | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "TAG=$TAG" >> $GITHUB_ENV | |
| echo "Deploying version: $VERSION (from tag: $TAG)" | |
| - name: Deploy MkDocs using Mike | |
| env: | |
| GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }} | |
| run: | | |
| poetry run mike delete dev || true | |
| poetry run mike delete latest || true | |
| poetry run mike deploy --update-aliases ${VERSION} latest | |
| poetry run mike set-default latest | |
| - name: Update Root Files (Verification + Robots.txt) | |
| run: | | |
| git checkout gh-pages | |
| # Copy verification file if exists | |
| cp ${VERSION}/googleb888a8ce45bda477.html . || echo "Verification file not found in version, skipping" | |
| # Generate robots.txt | |
| echo "User-agent: *" > robots.txt | |
| echo "Sitemap: https://open-ev-data.github.io/latest/sitemap.xml" >> robots.txt | |
| git add googleb888a8ce45bda477.html robots.txt | |
| git commit -m "chore: update root files (verification + robots.txt)" || echo "No changes to commit" | |
| - name: Push Changes | |
| run: | | |
| git push origin gh-pages |