diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3015475c7..c83598837 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,24 +1,40 @@ name: Build Documentation on: push: + tags: [ '*.*.*' ] branches: - - '**' - tags-ignore: - - '**' + - main + - dev + jobs: deploy-docs: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2.3.1 - - name: Install and Build + - name: Install Python dependencies run: | - bash build/bin/build-docs.sh + python -m pip install -q mkdocs + python -m pip install -q mkdocs-redirects + python -m pip install -q mkdocs-macros-plugin + python -m pip install -q mkdocs-drawio-file + python -m pip install -q mike + + - name: Checkout + uses: actions/checkout@v4 + + # GITHUB_REF is one of the following: "refs/heads/main", "refs/heads/dev", "refs/tags/x.x.x" + # We use this to determine the version of documentation that we want to publish; one of: "main", "dev" or "x.x" + # Note: the latter is deliberately "x.x" (not "x.x.x") so we group docs by minor release; each version of the docs will correspond to the latest patch release for that minor version. + # The command uses sed/regex to pull out "main", "dev" or "x.x" and assign it to the "branch" output of this step, accessible in later steps via ${{ steps.get_branch_name.outputs.branch }}" + - name: Get branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF} | sed -rn "s/refs\/(tags\/([0-9]+\.[0-9]+).*|heads\/(.*))/\2\3/p")" + id: get_branch_name - - name: Deploy - uses: JamesIves/github-pages-deploy-action@4.1.7 - if: github.ref == 'refs/heads/main' - with: - branch: gh-pages - folder: site + - name: Deploy with mike 🚀 + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git fetch origin gh-pages --depth=1 + echo "Pushing docs for version ${{ steps.get_branch_name.outputs.branch }}" + mike deploy --push ${{ steps.get_branch_name.outputs.branch }} \ No newline at end of file diff --git a/build/bin/build-docs.sh b/build/bin/build-docs.sh deleted file mode 100644 index bac9e50a8..000000000 --- a/build/bin/build-docs.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -python -m pip install -q mkdocs mkdocs-redirects -python -m pip install -q mkdocs mkdocs-macros-plugin -python -m pip install -q mkdocs mkdocs-drawio-file -mkdocs build --verbose --clean --strict \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index edfab7038..09d2e9c35 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,5 +1,3 @@ -# mkdocs serve - site_name: MAS GitOps site_url: https://pages.github.com/ibm-mas/gitops