diff --git a/.github/workflows/deploy-docs.yaml b/.github/workflows/deploy-docs.yaml index 87a66cb1f..7b1ec46c2 100644 --- a/.github/workflows/deploy-docs.yaml +++ b/.github/workflows/deploy-docs.yaml @@ -19,7 +19,7 @@ jobs: if: ${{ !github.event.release.prerelease }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@main with: fetch-depth: 0 - name: get_tags @@ -56,13 +56,13 @@ jobs: if: github.repository_owner == 'emqx' steps: - name: clone docs - uses: actions/checkout@v3 + uses: actions/checkout@main with: fetch-depth: 0 path: docs-files - name: clone frontend - uses: actions/checkout@v3 + uses: actions/checkout@main with: repository: 'emqx/docs-emqx-com-frontend' ref: next @@ -70,20 +70,19 @@ jobs: path: frontend - name: use node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: - node-version: 16 + node-version-file: 'frontend/.nvmrc' - name: use pnpm uses: pnpm/action-setup@v2 with: - version: 8.5.1 + version: 8 - name: use python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.8' - architecture: 'x64' - name: set env run: | @@ -115,7 +114,21 @@ jobs: pnpm install pnpm build - - name: upload dist + - 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 docs-1302406139 -r ap-shanghai