|
| 1 | +name: Build and Publish Docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - develop |
| 7 | + workflow_dispatch: |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + |
| 11 | +# Ensure only one concurrent deployment |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref}} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +# Restrict permissions by default |
| 17 | +permissions: |
| 18 | + contents: write # Required for committing to gh-pages |
| 19 | + pages: write # Required for deploying to Pages |
| 20 | + pull-requests: write # Required for PR comments |
| 21 | + |
| 22 | +jobs: |
| 23 | + deploy: |
| 24 | + name: Publish Docs |
| 25 | + runs-on: ubuntu-latest |
| 26 | + timeout-minutes: 10 |
| 27 | + strategy: |
| 28 | + matrix: |
| 29 | + python-version: ["3.10"] |
| 30 | + steps: |
| 31 | + - name: 📥 Checkout the repository |
| 32 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 33 | + with: |
| 34 | + fetch-depth: 0 |
| 35 | + |
| 36 | + - name: 🐍 Install uv and set Python ${{ matrix.python-version }} |
| 37 | + uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1 |
| 38 | + with: |
| 39 | + python-version: ${{ matrix.python-version }} |
| 40 | + activate-environment: true |
| 41 | + |
| 42 | + |
| 43 | + - name: 🔑 Create GitHub App token (mkdocs) |
| 44 | + id: mkdocs_token |
| 45 | + uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 |
| 46 | + with: |
| 47 | + app-id: ${{ secrets.MKDOCS_APP_ID }} |
| 48 | + private-key: ${{ secrets.MKDOCS_PEM }} |
| 49 | + owner: roboflow |
| 50 | + repositories: mkdocs-material-insiders |
| 51 | + |
| 52 | + - name: 🏗️ Install dependencies |
| 53 | + run: | |
| 54 | + uv pip install -r pyproject.toml --group docs |
| 55 | + # Install mkdocs-material-insiders using the GitHub App token |
| 56 | + uv pip install "git+https://roboflow:${{ steps.mkdocs_token.outputs.token }}@github.com/roboflow/mkdocs-material-insiders.git@9.5.49-insiders-4.53.14#egg=mkdocs-material[imaging]" |
| 57 | +
|
| 58 | + - name: ⚙️ Configure git for github-actions |
| 59 | + run: | |
| 60 | + git config --global user.name "github-actions[bot]" |
| 61 | + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 62 | +
|
| 63 | + - name: 🚀 Deploy Development Docs |
| 64 | + if: (github.event_name == 'push' && github.ref == 'refs/heads/develop') || github.event_name == 'workflow_dispatch' |
| 65 | + run: | |
| 66 | + MKDOCS_GIT_COMMITTERS_APIKEY=${{ secrets.GITHUB_TOKEN }} uv run mike deploy --push develop |
| 67 | +
|
| 68 | + - name: 🚀 Deploy Release Docs |
| 69 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 70 | + run: | |
| 71 | + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) |
| 72 | + MKDOCS_GIT_COMMITTERS_APIKEY=${{ secrets.GITHUB_TOKEN }} uv run mike deploy --push --update-aliases $latest_tag latest |
0 commit comments