Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): fix deploy ci for 2.7 #514

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/scripts/remove_unused.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import sys
import json

directory_file = sys.argv[1]
docs_path = sys.argv[2]
docs_path = sys.argv[1]


def get_markdown_file(dir_config, base_path):
Expand All @@ -20,7 +19,7 @@ def get_markdown_file(dir_config, base_path):


if __name__ == '__main__':
r = open(f'{docs_path}/{directory_file}', 'r')
r = open(f'{docs_path}/directory.json', 'r')
directory_config = json.load(r)
markdown_files = get_markdown_file(directory_config['cn'], f'{docs_path}/zh_CN')
markdown_files += get_markdown_file(directory_config['en'], f'{docs_path}/en_US')
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/check_markdown.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check markdown
name: Check Docs

on: [push, pull_request]

Expand All @@ -8,6 +8,7 @@ jobs:
steps:
- name: check out code
uses: actions/checkout@main

- name: install markdownlint
run: sudo npm install -g markdownlint-cli

Expand Down
63 changes: 37 additions & 26 deletions .github/workflows/deploy_docs.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy Docs

concurrency:
group: ${{ github.ref }}
group: ${{ github.ref_name }}
cancel-in-progress: true

on:
Expand All @@ -25,23 +25,18 @@ jobs:
- name: clone frontend
uses: actions/checkout@main
with:
repository: 'emqx/emqx-io-docs-frontend'
token: ${{ secrets.CI_GIT_TOKEN }}
repository: 'emqx/docs-emqx-com-frontend'
ref: next
token: ${{ secrets.CI_GIT_TOKEN }}
path: frontend

- name: use python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: use node.js
uses: actions/setup-node@v3
with:
node-version-file: 'frontend/.nvmrc'

- name: use pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v4
with:
version: 8

Expand All @@ -60,17 +55,19 @@ jobs:
- name: remove unused files
run: |
cd docs-files
python3 .github/scripts/remove_unused.py directory.json $(pwd)
python3 .github/scripts/remove_unused.py $(pwd)

- name: move files
run: |
rm frontend/docs/en/index.md || true
rm frontend/docs/zh/index.md || true
rm frontend/docs/*.md || true
rm frontend/README.md || true
mkdir -p frontend/docs/en/${VERSION}/
mkdir -p frontend/docs/zh/${VERSION}/
rm frontend/index.md || true
mkdir -p frontend/docs/en/${DOCS_TYPE}/${VERSION}/
mkdir -p frontend/docs/zh/${DOCS_TYPE}/${VERSION}/
mkdir -p frontend/docs/public/api/
cp -r docs-files/en_US/* frontend/docs/en/${VERSION}/
cp -r docs-files/zh_CN/* frontend/docs/zh/${VERSION}/
cp -r docs-files/en_US/* frontend/docs/en/${DOCS_TYPE}/${VERSION}/
cp -r docs-files/zh_CN/* frontend/docs/zh/${DOCS_TYPE}/${VERSION}/
cp docs-files/directory.json frontend/docs/.vitepress/config/directory.json

- name: generate version config
Expand All @@ -85,23 +82,37 @@ jobs:
pnpm install
pnpm build

- name: set aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}

- name: upload dist to s3
run: |
aws s3 rm --recursive s3://docs-emqx-com/zh/${DOCS_TYPE}/${VERSION} || true
aws s3 rm --recursive s3://docs-emqx-com/en/${DOCS_TYPE}/${VERSION} || true
aws s3 cp --recursive frontend/docs/.vitepress/dist/ s3://docs-emqx-com/
aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_DOCS_CLOUDFRONT_ID }} --paths "/zh/${DOCS_TYPE}/${VERSION}/*" "/en/${DOCS_TYPE}/${VERSION}/*" "/api/${DOCS_TYPE}_versions.json" "/sitemap_${DOCS_TYPE}_${VERSION}.xml"

- name: upload dist to cos
run: |
pip3 install coscmd
coscmd config -a ${{ secrets.TENCENT_COS_ID }} -s ${{ secrets.TENCENT_COS_KEY }} -b neugates-io-1302406139 -r ap-hongkong
coscmd delete -r -f docs/en/${VERSION} || true
coscmd delete -r -f docs/zh/${VERSION} || true
coscmd config -a ${{ secrets.TENCENT_COS_ID }} -s ${{ secrets.TENCENT_COS_KEY }} -b neugates-io-1302406139 -e cos.accelerate.myqcloud.com
cd frontend/docs/.vitepress/
coscmd upload -r dist/ /docs/

- name: refresh cdn cache
coscmd config -a ${{ secrets.TENCENT_COS_ID }} -s ${{ secrets.TENCENT_COS_KEY }} -b docs-1302406139 -r ap-shanghai
coscmd delete -r -f en/${DOCS_TYPE}/${VERSION} || true
coscmd delete -r -f zh/${DOCS_TYPE}/${VERSION} || true
coscmd config -a ${{ secrets.TENCENT_COS_ID }} -s ${{ secrets.TENCENT_COS_KEY }} -b docs-1302406139 -e cos.accelerate.myqcloud.com
coscmd upload -r frontend/docs/.vitepress/dist/ /

- name: flush cdn
run: |
pip3 install tccli
tccli configure set secretId ${{ secrets.TENCENT_COS_ID }}
tccli configure set secretKey ${{ secrets.TENCENT_COS_KEY }}
tccli configure set region ap-hongkong
tccli cdn PurgePathCache --Paths '["https://neugates.io/docs/", "https://neuron-docs.emqx.net"]' --FlushType delete
tccli configure set region ap-shanghai
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: update search index
uses: Swilder-M/docsearch-scraper-simple@next
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/markdown_config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"default": false,
"MD001": true,
"MD003": {"style": "atx"},
"MD011": true,
"MD018": true,
"MD019": true,
"MD023": true,
"MD025": {"level": 1, "front_matter_title": ""},
"MD042": true,
"MD046": {"style": "fenced"},
"MD048": {"style": "backtick"}
}
"default": false,
"MD001": true,
"MD003": {"style": "atx"},
"MD011": true,
"MD018": true,
"MD019": true,
"MD023": true,
"MD025": {"level": 1, "front_matter_title": ""},
"MD042": true,
"MD046": {"style": "fenced"},
"MD048": {"style": "backtick"}
}