Repository navigation
fix: push core docs release to gh-pages once #17
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: Publish versioned core documentation | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "[0-9]*" | |
| paths: | |
| - docs/** | |
| - boards.txt | |
| - mkdocs.yml | |
| - requirements-docs.txt | |
| - .github/workflows/publish-docs.yml | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: publish-root-docs | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - uses: actions/setup-python@v7 | |
| with: | |
| python-version: "3.x" | |
| - run: python -m pip install -r requirements-docs.txt | |
| - name: Configure Git author | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - uses: actions/create-github-app-token@v3 | |
| id: pages-token | |
| with: | |
| client-id: ${{ vars.DOCS_PUBLISH_APP_CLIENT_ID }} | |
| private-key: ${{ secrets.DOCS_PUBLISH_APP_PRIVATE_KEY }} | |
| owner: stm32duino | |
| repositories: stm32duino.github.io | |
| permission-contents: write | |
| - name: Configure Pages remote | |
| env: | |
| PAGES_TOKEN: ${{ steps.pages-token.outputs.token }} | |
| run: git remote add pages "https://x-access-token:${PAGES_TOKEN}@github.com/stm32duino/stm32duino.github.io.git" | |
| - name: Fetch published documentation | |
| run: | | |
| if git ls-remote --exit-code --heads pages gh-pages >/dev/null; then | |
| git fetch pages gh-pages | |
| fi | |
| - name: Publish development documentation | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| if git ls-remote --exit-code --heads pages gh-pages >/dev/null; then | |
| mike deploy --remote pages --branch gh-pages --push dev | |
| else | |
| mike deploy --remote pages --branch gh-pages --push dev | |
| mike set-default --remote pages --branch gh-pages --push dev | |
| fi | |
| - name: Publish release documentation | |
| if: startsWith(github.ref, 'refs/tags/') | |
| env: | |
| VERSION: ${{ github.ref_name }} | |
| run: | | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Unsupported documentation release tag: $VERSION" >&2 | |
| exit 1 | |
| fi | |
| latest=$(git tag --list | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1) | |
| if git ls-remote --exit-code --heads pages gh-pages >/dev/null; then | |
| git fetch pages gh-pages:gh-pages | |
| fi | |
| if [[ "$VERSION" == "$latest" ]]; then | |
| mike deploy --branch gh-pages --update-aliases "$VERSION" latest | |
| mike set-default --branch gh-pages latest | |
| else | |
| mike deploy --branch gh-pages "$VERSION" | |
| fi | |
| # One push so GitHub Pages builds the site once. | |
| git push pages gh-pages |