Skip to content

Commit

Permalink
Merge pull request #9 from ty-dc/pr/mkdocs-version
Browse files Browse the repository at this point in the history
support multiple versions of documents
  • Loading branch information
ty-dc authored Aug 30, 2023
2 parents b6bb19b + 5cf3e66 commit e794cce
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions .github/workflows/call-release-doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ env:
PR_REVIWER: weizhoublue

jobs:
get_ref:
release_doc:
runs-on: ubuntu-latest
outputs:
ref: ${{ env.REF }}
Expand Down Expand Up @@ -69,7 +69,8 @@ jobs:
id: extract
run: |
if ! grep -E "^[[:space:]]*v[0-9]+.[0-9]+.[0-9]+[[:space:]]*$" VERSION &>/dev/null ; then
echo "Skip, your version should be in vx.y.z format, not something else like v0.6.0-rc1."
echo "not a release version, skip generating doc."
cat VERSION
echo "SKIP_ALL_JOB=true" >> $GITHUB_ENV
exit 0
fi
Expand All @@ -78,7 +79,7 @@ jobs:
if [ -n "${docVersion}" ]; then
echo "the version intercepted from the branch is: ${docVersion}"
else
echo "error, failed to get version, is your version in v0.6.* format?" && exit 1
echo "error, failed to get version." && exit 1
fi
git checkout -f ${{ env.MERGE_BRANCH }}
echo "Switch to the branch:${{ env.MERGE_BRANCH }} where the document is located"
Expand All @@ -93,23 +94,24 @@ jobs:
echo "the doc version is: ${docVersion}"
echo "DOCS_TAG=${docVersion}" >> $GITHUB_ENV
build_doc:
runs-on: ubuntu-latest
needs: get_ref
if: ${{ needs.get_ref.outputs.skip_all_job != 'true' }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ needs.get_ref.outputs.ref }}

- name: build doc
id: build_doc
if: ${{ env.SKIP_ALL_JOB != 'true' }}
run: |
git checkout ${{ env.REF }}
ls
echo "switch to the release version branch ${{ env.REF }}"
pip install mkdocs==1.5.2 mike==1.1.2 mkdocs-material==8.5.11
git config user.email "[email protected]"
git config user.name "robot"
cp ./docs/mkdocs.yml ./
if ${{ env.SET_LATEST == 'true' }} ;then
echo "generate doc version:${{ env.DOCS_TAG }} and set to latest."
mike deploy --rebase --prefix ${{ env.DEST_DIRECTORY }} -b ${{ env.MERGE_BRANCH }} --update-aliases ${{env.DOCS_TAG }} latest
mike set-default --prefix ${{ env.DEST_DIRECTORY }} -b ${{ env.MERGE_BRANCH }} latest
else
echo "the version:${{ env.DOCS_TAG }} of the doc does not need to be set to the latest."
mike deploy --rebase --prefix ${{ env.DEST_DIRECTORY }} -b ${{ env.MERGE_BRANCH }} ${{ env.DOCS_TAG }}
if ${{ needs.get_ref.outputs.set_latest == 'true' }} ;then
echo "generate doc version:${{ needs.get_ref.outputs.docs_tag }} and set to latest."
mike deploy --rebase --prefix ${{ env.DEST_DIRECTORY }} -b ${{ env.MERGE_BRANCH }} --update-aliases ${{ needs.get_ref.outputs.docs_tag }} latest
Expand All @@ -121,12 +123,12 @@ jobs:
rm -rf ./site
rm -rf ./mkdocs.yml
git checkout -f ${{ env.MERGE_BRANCH }}
echo "Push a doc version: ${{ needs.get_ref.outputs.docs_tag }} from branch: ${{ needs.get_ref.outputs.ref }}, update it to latest: ${{ needs.get_ref.outputs.set_latest }} "
echo "Push a doc version: ${{ env.DOCS_TAG }} from branch: ${{ env.REF }}, update it to latest: ${{ env.SET_LATEST }} "
# Allow auto-merge on general
- name: Create Pull Request
id: create_pr
if: ${{ needs.get_ref.outputs.submit == 'true' }}
if: ${{ env.SUBMIT == 'true' }}
uses: peter-evans/[email protected]
with:
title: "robot update website from ${{ needs.prepare_doc.outputs.ref }} to branch ${{ env.MERGE_BRANCH }} "
Expand Down

0 comments on commit e794cce

Please sign in to comment.