From 76f1f8bd90b95f2c16a9456bdee8108a542f385f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Wed, 25 Mar 2026 17:18:24 +0800 Subject: [PATCH] chore(ci): upgrade actions version --- .github/workflows/check-db.yml | 74 +++++------ .github/workflows/pr-comment-ci.yml | 186 +++++++++++++-------------- .github/workflows/pr-spell-check.yml | 4 +- .github/workflows/sync-to-cnb.yml | 65 +++++----- 4 files changed, 164 insertions(+), 165 deletions(-) diff --git a/.github/workflows/check-db.yml b/.github/workflows/check-db.yml index 6a7567512..eda409c02 100644 --- a/.github/workflows/check-db.yml +++ b/.github/workflows/check-db.yml @@ -1,44 +1,44 @@ name: check-db on: - push: - branches: [main] - pull_request: - branches: [main] - types: [opened, synchronize, reopened] + push: + branches: [main] + pull_request: + branches: [main] + types: [opened, synchronize, reopened] concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: - check-db: - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - uses: pnpm/action-setup@v4 - - - uses: actions/setup-node@v4 - with: - cache: 'pnpm' - - - name: Install Dependencies - run: pnpm install --frozen-lockfile - - - name: Start Service - run: pnpm run dev & - - - name: Update api.json - run: pnpm run api:download - - - name: Check Diff - run: | - IS_DIFF=$(if git status | grep -q "packages/scripts/api.json"; then echo "true"; else echo "false"; fi) - echo "IS_DIFF: $IS_DIFF" - if [[ $IS_DIFF == 'true' ]]; then - git diff packages/scripts/api.json - echo "TDesign.db and api.json data inconsistency. Workflow will fail." - exit 1 - fi \ No newline at end of file + check-db: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v6 + + - uses: pnpm/action-setup@v5 + + - uses: actions/setup-node@v6 + with: + cache: 'pnpm' + + - name: Install Dependencies + run: pnpm install --frozen-lockfile + + - name: Start Service + run: pnpm run dev & + + - name: Update api.json + run: pnpm run api:download + + - name: Check Diff + run: | + IS_DIFF=$(if git status | grep -q "packages/scripts/api.json"; then echo "true"; else echo "false"; fi) + echo "IS_DIFF: $IS_DIFF" + if [[ $IS_DIFF == 'true' ]]; then + git diff packages/scripts/api.json + echo "TDesign.db and api.json data inconsistency. Workflow will fail." + exit 1 + fi diff --git a/.github/workflows/pr-comment-ci.yml b/.github/workflows/pr-comment-ci.yml index d599ee26b..6d1ff1daf 100644 --- a/.github/workflows/pr-comment-ci.yml +++ b/.github/workflows/pr-comment-ci.yml @@ -1,106 +1,106 @@ name: pr-comment-ci on: - issue_comment: - types: [created] + issue_comment: + types: [created] jobs: - check: - runs-on: ubuntu-latest - outputs: - next_action: ${{ steps.get-action.outputs.next_action }} - if: ${{ github.event.issue.pull_request }} - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/CODEOWNERS - sparse-checkout-cone-mode: false - - uses: actions/github-script@v7 - id: get-action - with: - script: | - const user = context.payload.comment.user.login - core.debug(`user: ${user}`) + check: + runs-on: ubuntu-latest + outputs: + next_action: ${{ steps.get-action.outputs.next_action }} + if: ${{ github.event.issue.pull_request }} + steps: + - uses: actions/checkout@v6 + with: + sparse-checkout: | + .github/CODEOWNERS + sparse-checkout-cone-mode: false + - uses: actions/github-script@v8 + id: get-action + with: + script: | + const user = context.payload.comment.user.login + core.debug(`user: ${user}`) - const fs = require('fs') - const CODEOWNERS = fs.readFileSync('.github/CODEOWNERS', 'utf8') - core.debug(`CODEOWNERS: ${CODEOWNERS}`) + const fs = require('fs') + const CODEOWNERS = fs.readFileSync('.github/CODEOWNERS', 'utf8') + core.debug(`CODEOWNERS: ${CODEOWNERS}`) - let isReviewer = false; - CODEOWNERS.match(/@\w+/g).forEach((owner) => { - if (owner === `@${user}`) { - isReviewer = true - } - }) + let isReviewer = false; + CODEOWNERS.match(/@\w+/g).forEach((owner) => { + if (owner === `@${user}`) { + isReviewer = true + } + }) - let next_action = '' - if (isReviewer) { - const body = context.payload.comment.body - core.info(`body: ${body}`) - if (body.startsWith('/resolve-conflict')) { - next_action='resolve-conflict' - } - if(next_action){ - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: 'rocket', - }) - } - } else { - core.warning('You are not collaborator'); - } - core.info(`next_action: ${next_action}`) - core.setOutput('next_action', next_action) - - resolve-conflict: - needs: check - runs-on: ubuntu-latest - if: ${{ needs.check.outputs.next_action == 'resolve-conflict' }} - steps: - - uses: actions/checkout@v4 - with: - token: ${{ secrets.PERSONAL_TOKEN }} - fetch-depth: 0 - - name: gh checkout pr - env: - GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }} - run: gh pr checkout ${{ github.event.issue.number }} + let next_action = '' + if (isReviewer) { + const body = context.payload.comment.body + core.info(`body: ${body}`) + if (body.startsWith('/resolve-conflict')) { + next_action='resolve-conflict' + } + if(next_action){ + await github.rest.reactions.createForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: context.payload.comment.id, + content: 'rocket', + }) + } + } else { + core.warning('You are not collaborator'); + } + core.info(`next_action: ${next_action}`) + core.setOutput('next_action', next_action) - - uses: pnpm/action-setup@v4 + resolve-conflict: + needs: check + runs-on: ubuntu-latest + if: ${{ needs.check.outputs.next_action == 'resolve-conflict' }} + steps: + - uses: actions/checkout@v6 + with: + token: ${{ secrets.PERSONAL_TOKEN }} + fetch-depth: 0 + - name: gh checkout pr + env: + GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }} + run: gh pr checkout ${{ github.event.issue.number }} - - uses: actions/setup-node@v4 - with: - cache: 'pnpm' + - uses: pnpm/action-setup@v5 - - name: Install Dependencies - run: pnpm install --frozen-lockfile + - uses: actions/setup-node@v6 + with: + cache: 'pnpm' - - name: Merge main - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git merge main --no-commit || true - - - name: Resolve conflict - run: | - git status - conflict_count=$(git status | grep -c 'both modified:') || true - db_conflict=$(git status | grep 'both modified:' | grep -c 'db/TDesign.db') || true - echo "conflict_count $conflict_count" - echo "db_conflict $db_conflict" + - name: Install Dependencies + run: pnpm install --frozen-lockfile - if [ "$conflict_count" -eq "$db_conflict" ]&&[ "$conflict_count" -eq "1" ]; then - git checkout --theirs db/TDesign.db - git add db/TDesign.db - git status - nohup pnpm run dev & - sleep 10 - pnpm api:upload - git commit -am "chore: resolve conflict" - git push - else - echo "Condition not established." - fi \ No newline at end of file + - name: Merge main + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git merge main --no-commit || true + + - name: Resolve conflict + run: | + git status + conflict_count=$(git status | grep -c 'both modified:') || true + db_conflict=$(git status | grep 'both modified:' | grep -c 'db/TDesign.db') || true + echo "conflict_count $conflict_count" + echo "db_conflict $db_conflict" + + if [ "$conflict_count" -eq "$db_conflict" ]&&[ "$conflict_count" -eq "1" ]; then + git checkout --theirs db/TDesign.db + git add db/TDesign.db + git status + nohup pnpm run dev & + sleep 10 + pnpm api:upload + git commit -am "chore: resolve conflict" + git push + else + echo "Condition not established." + fi diff --git a/.github/workflows/pr-spell-check.yml b/.github/workflows/pr-spell-check.yml index 23aa30d6b..8c2be005a 100644 --- a/.github/workflows/pr-spell-check.yml +++ b/.github/workflows/pr-spell-check.yml @@ -2,5 +2,5 @@ name: pr-spell-check on: [pull_request] jobs: - run: - uses: TDesignOteam/workflows/.github/workflows/spell-check.yml@main + run: + uses: TDesignOteam/workflows/.github/workflows/spell-check.yml@main diff --git a/.github/workflows/sync-to-cnb.yml b/.github/workflows/sync-to-cnb.yml index 55b8c58ef..f3ad5ace1 100644 --- a/.github/workflows/sync-to-cnb.yml +++ b/.github/workflows/sync-to-cnb.yml @@ -1,37 +1,36 @@ name: sync-to-cnb -on: - - push - - delete +on: + - push + - delete jobs: - sync-push: - if: ${{ github.repository == 'TDesignOteam/tdesign-api' && github.event_name == 'push' }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Sync to CNB Repository - run: | - docker run --rm \ - -v ${{ github.workspace }}:${{ github.workspace }} \ - -w ${{ github.workspace }} \ - -e PLUGIN_TARGET_URL="https://cnb.cool/tencent/tdesign/tdesign-api.git" \ - -e PLUGIN_AUTH_TYPE="https" \ - -e PLUGIN_USERNAME="cnb" \ - -e PLUGIN_PASSWORD=${{ secrets.CNB_TOKEN }} \ - -e PLUGIN_FORCE="true" \ - tencentcom/git-sync + sync-push: + if: ${{ github.repository == 'TDesignOteam/tdesign-api' && github.event_name == 'push' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 - sync-delete-branch: - if: ${{ github.repository == 'TDesignOteam/tdesign-api' && github.event_name == 'delete' && github.event.ref_type == 'branch' }} - runs-on: ubuntu-latest - steps: - - uses: TDesignOteam//tdesign-pr-trigger-action@develop - with: - repo: 'tencent/tdesign/tdesign-api' - token: ${{ secrets.CNB_TOKEN }} - branch: ${{ github.event.ref }} - trigger: '/delete-cnb-branch' - + - name: Sync to CNB Repository + run: | + docker run --rm \ + -v ${{ github.workspace }}:${{ github.workspace }} \ + -w ${{ github.workspace }} \ + -e PLUGIN_TARGET_URL="https://cnb.cool/tencent/tdesign/tdesign-api.git" \ + -e PLUGIN_AUTH_TYPE="https" \ + -e PLUGIN_USERNAME="cnb" \ + -e PLUGIN_PASSWORD=${{ secrets.CNB_TOKEN }} \ + -e PLUGIN_FORCE="true" \ + tencentcom/git-sync + + sync-delete-branch: + if: ${{ github.repository == 'TDesignOteam/tdesign-api' && github.event_name == 'delete' && github.event.ref_type == 'branch' }} + runs-on: ubuntu-latest + steps: + - uses: TDesignOteam//tdesign-pr-trigger-action@develop + with: + repo: 'tencent/tdesign/tdesign-api' + token: ${{ secrets.CNB_TOKEN }} + branch: ${{ github.event.ref }} + trigger: '/delete-cnb-branch'