From a491d842db47c72c88ac6919a5ab4964ef84a66a Mon Sep 17 00:00:00 2001 From: yanyongyu <42488585+yanyongyu@users.noreply.github.com> Date: Wed, 16 Feb 2022 14:17:33 +0800 Subject: [PATCH 1/6] :construction_worker: reduce ci redundant run --- .github/workflows/codecov.yml | 4 +- .github/workflows/release-drafter.yml | 3 ++ .github/workflows/website-deploy.yml | 54 ++++++++++++++++++++------- .pre-commit-config.yaml | 4 +- website/src/pages/changelog.md | 9 +---- 5 files changed, 50 insertions(+), 24 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index f1f2cf14..aa7a4b64 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -4,13 +4,15 @@ on: push: branches: - master - - dev pull_request: jobs: test: name: Test Coverage runs-on: ${{ matrix.os }} + concurrency: + group: test-coverage-${{ github.ref }} + cancel-in-progress: true strategy: matrix: python-version: ["3.7", "3.8", "3.9", "3.10"] diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 2739ad12..bf4cfbf1 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -14,6 +14,9 @@ jobs: update-release-draft: if: github.event_name == 'pull_request_target' runs-on: ubuntu-latest + concurrency: + group: pull-request-changelog + cancel-in-progress: true steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/website-deploy.yml b/.github/workflows/website-deploy.yml index 9d6c3bd8..35a169ec 100644 --- a/.github/workflows/website-deploy.yml +++ b/.github/workflows/website-deploy.yml @@ -4,22 +4,20 @@ on: push: branches: - master - - dev pull_request_target: jobs: publish: + if: github.event_name == 'push' runs-on: ubuntu-latest + concurrency: + group: website-deploy-${{ github.ref }} + cancel-in-progress: true steps: - uses: actions/checkout@v2 if: github.event_name == 'push' - - uses: actions/checkout@v2 - if: github.event_name != 'push' - with: - ref: ${{ github.event.pull_request.head.sha }} - - name: Setup Python Environment uses: ./.github/actions/setup-python @@ -35,23 +33,53 @@ jobs: - name: Get Branch Name run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV - - name: Get Deploy Name - if: github.event_name == 'push' - run: | - echo "DEPLOY_NAME=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV - echo "PRODUCTION=${{ env.BRANCH_NAME == 'master' }}" >> $GITHUB_ENV + - name: Deploy to Netlify + uses: nwtgck/actions-netlify@v1 + with: + publish-dir: "./website/build" + production-deploy: true + github-token: ${{ secrets.GITHUB_TOKEN }} + deploy-message: "Deploy ${{ env.BRANCH_NAME }}@${{ github.sha }}" + enable-commit-comment: false + alias: ${{ env.BRANCH_NAME }} + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.SITE_ID }} + + preview: + if: github.event_name == 'pull_request_target' + runs-on: ubuntu-latest + concurrency: + group: pull-request-preview-${{ github.event.number }} + cancel-in-progress: true + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup Python Environment + uses: ./.github/actions/setup-python + + - name: Setup Node Environment + uses: ./.github/actions/setup-node + + - name: Build API Doc + uses: ./.github/actions/build-api-doc + + - name: Build Doc + run: yarn build - name: Get Deploy Name if: github.event_name != 'push' run: | echo "DEPLOY_NAME=deploy-preview-${{ github.event.number }}" >> $GITHUB_ENV - echo "PRODUCTION=false" >> $GITHUB_ENV - name: Deploy to Netlify uses: nwtgck/actions-netlify@v1 with: publish-dir: "./website/build" - production-deploy: ${{ env.PRODUCTION }} + production-deploy: false github-token: ${{ secrets.GITHUB_TOKEN }} deploy-message: "Deploy ${{ env.DEPLOY_NAME }}@${{ github.sha }}" enable-commit-comment: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7811c634..cc626e4a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,8 @@ ci: autofix_commit_msg: ":rotating_light: auto fix by pre-commit hooks" autofix_prs: true - autoupdate_branch: dev - autoupdate_schedule: weekly + autoupdate_branch: master + autoupdate_schedule: monthly autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks" repos: - repo: https://github.com/pycqa/isort diff --git a/website/src/pages/changelog.md b/website/src/pages/changelog.md index a7b8d4a5..9c547878 100644 --- a/website/src/pages/changelog.md +++ b/website/src/pages/changelog.md @@ -13,14 +13,7 @@ description: Changelog ### 🍻 插件发布 -- Plugin: pixiv.net p站查询图片 [@yanyongyu](https://github.com/yanyongyu) ([#803](https://github.com/nonebot/nonebot2/pull/803)) - -## Latest changes - -### 💫 杂项 - -- CI: fix ci permission error [@yanyongyu](https://github.com/yanyongyu) ([#802](https://github.com/nonebot/nonebot2/pull/802)) -- CI: 添加更新日志自动更新 action [@yanyongyu](https://github.com/yanyongyu) ([#799](https://github.com/nonebot/nonebot2/pull/799)) +- Plugin: pixiv.net p 站查询图片 [@yanyongyu](https://github.com/yanyongyu) ([#803](https://github.com/nonebot/nonebot2/pull/803)) ## v2.0.0-beta.2 From 98e0ec27ee3bf58693ed7ba60bbfae6e3dc588e1 Mon Sep 17 00:00:00 2001 From: yanyongyu <42488585+yanyongyu@users.noreply.github.com> Date: Wed, 16 Feb 2022 14:19:26 +0800 Subject: [PATCH 2/6] :pencil2: fix changelog typo --- website/src/pages/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/src/pages/changelog.md b/website/src/pages/changelog.md index 9c547878..976b4927 100644 --- a/website/src/pages/changelog.md +++ b/website/src/pages/changelog.md @@ -4,7 +4,7 @@ description: Changelog # 更新日志 -## Latest changes +## Latest Changes ### 💫 杂项 From 004a308765c11a9e610446a90c87acff6eb13f39 Mon Sep 17 00:00:00 2001 From: yanyongyu <42488585+yanyongyu@users.noreply.github.com> Date: Wed, 16 Feb 2022 14:28:44 +0800 Subject: [PATCH 3/6] :construction_worker: disable auto push --- .github/workflows/release-drafter.yml | 14 ++++++++++++++ .github/workflows/release.yml | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index bf4cfbf1..e26442fc 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -22,6 +22,9 @@ jobs: with: token: ${{ secrets.GH_TOKEN }} + - name: Setup Node Environment + uses: ./.github/actions/setup-node + - uses: release-drafter/release-drafter@v5 id: release-drafter env: @@ -33,6 +36,17 @@ jobs: changelog_file: website/src/pages/changelog.md latest_changes_position: '# 更新日志\n\n' changelog_body: ${{ steps.release-drafter.outputs.body }} + commit_and_push: false + + - name: Commit and Push + run: | + yarn prettier + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + git add . + git commit -m ":memo: Update changelog" + git push + release: if: startsWith(github.ref, 'refs/tags/') diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4adacd67..25efa0ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,9 +29,12 @@ jobs: with: changelog_file: website/src/pages/changelog.md archive_title: ${{ env.TAG_NAME }} + commit_and_push: false - name: Archive Files - run: yarn archive $(poetry version -s) + run: | + yarn archive $(poetry version -s) + yarn prettier - name: Push Tag run: | From ab78769822bd0d003509f3d8ac6960e86bf61768 Mon Sep 17 00:00:00 2001 From: yanyongyu <42488585+yanyongyu@users.noreply.github.com> Date: Wed, 16 Feb 2022 14:41:39 +0800 Subject: [PATCH 4/6] :bug: fix concurrency missing matrix --- .github/workflows/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index aa7a4b64..ebdb0873 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -11,7 +11,7 @@ jobs: name: Test Coverage runs-on: ${{ matrix.os }} concurrency: - group: test-coverage-${{ github.ref }} + group: test-coverage-${{ github.ref }}-${{ matrix.os }}-${{ matrix.python-version }} cancel-in-progress: true strategy: matrix: From 6272dfd46a31f2bb24fe00e64fb2d1504fdc5848 Mon Sep 17 00:00:00 2001 From: yanyongyu <42488585+yanyongyu@users.noreply.github.com> Date: Wed, 16 Feb 2022 17:04:12 +0800 Subject: [PATCH 5/6] :fire: remove unused condition --- .github/workflows/website-deploy.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/website-deploy.yml b/.github/workflows/website-deploy.yml index 35a169ec..959f0eaf 100644 --- a/.github/workflows/website-deploy.yml +++ b/.github/workflows/website-deploy.yml @@ -16,7 +16,6 @@ jobs: steps: - uses: actions/checkout@v2 - if: github.event_name == 'push' - name: Setup Python Environment uses: ./.github/actions/setup-python @@ -71,7 +70,6 @@ jobs: run: yarn build - name: Get Deploy Name - if: github.event_name != 'push' run: | echo "DEPLOY_NAME=deploy-preview-${{ github.event.number }}" >> $GITHUB_ENV From 6f9c9eb7401870b2520bcc0b9bd10ef25f78b1de Mon Sep 17 00:00:00 2001 From: yanyongyu <42488585+yanyongyu@users.noreply.github.com> Date: Wed, 16 Feb 2022 17:51:17 +0800 Subject: [PATCH 6/6] :wrench: change latest changes to chinese --- .github/workflows/release-drafter.yml | 2 ++ .github/workflows/release.yml | 1 + website/src/pages/changelog.md | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index e26442fc..1b6200b2 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -35,6 +35,8 @@ jobs: with: changelog_file: website/src/pages/changelog.md latest_changes_position: '# 更新日志\n\n' + latest_changes_title: '## 最近更新' + replace_regex: '(?<=## 最近更新\n)[\s\S]*?(?=\n## )' changelog_body: ${{ steps.release-drafter.outputs.body }} commit_and_push: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 25efa0ac..434ad156 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,7 @@ jobs: uses: docker://ghcr.io/nonebot/auto-changelog:master with: changelog_file: website/src/pages/changelog.md + archive_regex: '(?<=## )最近更新(?=\n)' archive_title: ${{ env.TAG_NAME }} commit_and_push: false diff --git a/website/src/pages/changelog.md b/website/src/pages/changelog.md index 976b4927..f3a3abcc 100644 --- a/website/src/pages/changelog.md +++ b/website/src/pages/changelog.md @@ -4,7 +4,7 @@ description: Changelog # 更新日志 -## Latest Changes +## 最近更新 ### 💫 杂项