From 5902db9597c32bc525a6dbc7a8a1b898f28ad45d Mon Sep 17 00:00:00 2001 From: Ben Phelps Date: Fri, 29 Sep 2023 21:17:43 +0300 Subject: [PATCH] Create docs-publish.yml --- .github/workflows/docs-publish.yml | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/docs-publish.yml diff --git a/.github/workflows/docs-publish.yml b/.github/workflows/docs-publish.yml new file mode 100644 index 000000000..0985e47cf --- /dev/null +++ b/.github/workflows/docs-publish.yml @@ -0,0 +1,49 @@ +name: Docs + +on: + push: + tags: [ 'v*.*.*' ] + branches: ['main'] + workflow_dispatch: + +permissions: + contents: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: main + - uses: actions/setup-python@v4 + with: + python-version: 3.x + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + - uses: actions/cache@v3 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + - run: sudo apt-get install pngquant + - run: pip install mike + - run: pip install git+https://${GH_TOKEN}@github.com/benphelps/mkdocs-material-insiders.git + - name: Set Git config + run: | + git config --global user.name "GitHub Action" + git config --global user.email "action@github.com" + - name: Sync gh-pages + run: | + git fetch origin gh-pages + git checkout gh-pages + git pull origin gh-pages + git checkout main + - name: Mike Deploy for Main + if: github.ref == 'refs/heads/main' + run: mike deploy --update --push ${{github.ref_name}} + - name: Mike Deploy for Tags + if: github.ref != 'refs/heads/main' + run: mike deploy --update --push ${{github.ref_name}} latest +env: + GH_TOKEN: ${{ secrets.GH_TOKEN }}