chore: dump version to 1.2.7-ecp.4 #94
Workflow file for this run
This file contains 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: Deploy Docs | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
push: | |
tags: | |
- "*" | |
jobs: | |
deploy: | |
strategy: | |
fail-fast: false | |
matrix: | |
ref: | |
- "latest" | |
- "" | |
runs-on: ubuntu-20.04 | |
if: github.repository_owner == 'emqx' | |
steps: | |
- name: clone docs | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
path: docs-files | |
- name: clone frontend | |
uses: actions/checkout@v2 | |
with: | |
repository: 'emqx/docs-emqx-com-frontend' | |
token: ${{ secrets.CI_GIT_TOKEN }} | |
path: frontend | |
- name: use node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 14.15 | |
- name: use python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
architecture: 'x64' | |
- name: set env | |
run: | | |
if [ "${{ matrix.ref }}" == "latest" ]; then | |
echo "VERSION=latest" >> $GITHUB_ENV | |
else | |
echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV | |
fi | |
echo "DOCS_TYPE=emqx-operator" >> $GITHUB_ENV | |
- name: remove unused files | |
run: | | |
cd docs-files | |
python3 .github/scripts/remove_unused.py $(pwd)/docs | |
- name: move files | |
run: | | |
rm frontend/docs/en/README.md || true | |
rm frontend/docs/zh/README.md || true | |
rm frontend/docs/*.md || true | |
rm frontend/README.md | |
mkdir -p frontend/docs/en/${DOCS_TYPE}/${VERSION}/ | |
mkdir -p frontend/docs/zh/${DOCS_TYPE}/${VERSION}/ | |
mkdir -p frontend/docs/.vuepress/public/api/ | |
cp -r docs-files/docs/en_US/* frontend/docs/en/${DOCS_TYPE}/${VERSION}/ | |
cp -r docs-files/docs/zh_CN/* frontend/docs/zh/${DOCS_TYPE}/${VERSION}/ | |
cp docs-files/docs/directory.json frontend/docs/.vuepress/config/directory.json | |
cd docs-files && git tag -l | egrep "^[1-9]\.[0-9]\.[0-9]?" | jq -R -s -c 'split("\n")[:-1] | . += ["latest"] | reverse' > ../frontend/docs/.vuepress/public/api/${DOCS_TYPE}_versions.json | |
- name: build docs | |
run: | | |
cd frontend | |
yarn && yarn build | |
- name: upload dist | |
run: | | |
pip3 install coscmd | |
coscmd config -a ${{ secrets.COS_ID }} -s ${{ secrets.COS_KEY }} -b ${{ secrets.COS_NAME }} -r ${{ secrets.COS_REGION }} | |
coscmd delete -r -f en/${DOCS_TYPE}/${VERSION} || true | |
coscmd delete -r -f zh/${DOCS_TYPE}/${VERSION} || true | |
coscmd config -a ${{ secrets.COS_ID }} -s ${{ secrets.COS_KEY }} -b ${{ secrets.COS_NAME }} -e cos.accelerate.myqcloud.com | |
cd frontend/docs/.vuepress/dist/ | |
zip -rq docs-dist-${DOCS_TYPE}-${VERSION}.zip ./ | |
coscmd upload docs-dist-${DOCS_TYPE}-${VERSION}.zip docs-zip/ | |
sleep 90 | |
- name: flush cdn | |
run: | | |
pip3 install tccli | |
tccli configure set secretId ${{ secrets.COS_ID }} | |
tccli configure set secretKey ${{ secrets.COS_KEY }} | |
tccli configure set region ${{ secrets.COS_REGION }} | |
tccli cdn PurgePathCache --cli-unfold-argument --Paths https://docs.emqx.com/zh/${DOCS_TYPE}/${VERSION}/ https://docs.emqx.com/en/${DOCS_TYPE}/${VERSION}/ --FlushType delete | |
tccli cdn PurgeUrlsCache --cli-unfold-argument --Urls https://docs.emqx.com/api/${DOCS_TYPE}_versions.json https://docs.emqx.com/sitemap_${DOCS_TYPE}_${VERSION}.xml | |
- name: clone docsearch | |
uses: actions/checkout@v2 | |
with: | |
repository: 'Swilder-M/docsearch-scraper-simple' | |
path: docsearch | |
- name: install pipenv | |
run: | | |
python -m pip install --upgrade pipenv wheel | |
- id: cache-pipenv | |
uses: actions/cache@v1 | |
with: | |
path: ~/.local/share/virtualenvs | |
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }} | |
- name: install dependencies | |
if: steps.cache-pipenv.outputs.cache-hit != 'true' | |
run: | | |
cd docsearch | |
pipenv install --keep-outdated | |
- name: update current version | |
if: env.VERSION == 'latest' | |
env: | |
APPLICATION_ID: ${{ secrets.DOCS_APPLICATION_ID }} | |
API_KEY: ${{ secrets.DOCS_API_KEY }} | |
run: | | |
cd docsearch | |
pipenv run python -m src.index config ${DOCS_TYPE} ${VERSION} |