From 2716da4220d8bcbc3406fd3359a98a97b491a0f5 Mon Sep 17 00:00:00 2001 From: YuBaoku <49938469+EmmonsCurse@users.noreply.github.com> Date: Wed, 19 Nov 2025 19:22:06 +0800 Subject: [PATCH] [CI] Add workflow to auto-remove `skip-ci` labels after new commits (#5129) * [CI] Add CI to automatically remove skip-ci labels after new commits --- .github/workflows/_unit_test_coverage.yml | 3 +- .github/workflows/remove-skip-ci-labels.yml | 53 +++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/remove-skip-ci-labels.yml diff --git a/.github/workflows/_unit_test_coverage.yml b/.github/workflows/_unit_test_coverage.yml index d46bee316..f06f41402 100644 --- a/.github/workflows/_unit_test_coverage.yml +++ b/.github/workflows/_unit_test_coverage.yml @@ -43,6 +43,7 @@ jobs: runs-on: [self-hosted, GPU-h1z1-2Cards] timeout-minutes: 90 needs: check_cov_skip + if: needs.check_cov_skip.outputs.can-skip != 'true' outputs: diff_cov_file_url: ${{ steps.cov_upload.outputs.diff_cov_file_url }} unittest_failed_url: ${{ steps.cov_upload.outputs.unittest_failed_url }} @@ -319,7 +320,7 @@ jobs: echo "All tests passed" - name: Verify Code Coverage Threshold (80%) - if: ${{ github.event_name == 'pull_request' && (needs.check_cov_skip.outputs['can-skip'] != 'true') }} + if: ${{ github.event_name == 'pull_request' }} shell: bash run: | cd FastDeploy diff --git a/.github/workflows/remove-skip-ci-labels.yml b/.github/workflows/remove-skip-ci-labels.yml new file mode 100644 index 000000000..6adc74158 --- /dev/null +++ b/.github/workflows/remove-skip-ci-labels.yml @@ -0,0 +1,53 @@ +name: Remove Skip-CI Labels + +on: + pull_request_target: + types: [synchronize] + +permissions: + pull-requests: write + +jobs: + remove-skip-ci-labels: + name: Remove skip-ci labels on new commits + runs-on: ubuntu-latest + steps: + - name: Get PR labels + id: get-labels + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + + const skipCiLabels = labels + .filter(label => label.name.startsWith('skip-ci:')) + .map(label => label.name); + + console.log('Found skip-ci labels:', skipCiLabels); + core.setOutput('skip-ci-labels', JSON.stringify(skipCiLabels)); + core.setOutput('has-skip-ci-labels', skipCiLabels.length > 0 ? 'true' : 'false'); + + - name: Remove skip-ci labels + if: steps.get-labels.outputs.has-skip-ci-labels == 'true' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const skipCiLabels = JSON.parse('${{ steps.get-labels.outputs.skip-ci-labels }}'); + + for (const label of skipCiLabels) { + console.log(`Removing label: ${label}`); + await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: label + }); + } + + console.log(`Successfully removed ${skipCiLabels.length} skip-ci label(s)`);