diff --git a/.github/actions/check-bypass/action.yml b/.github/actions/check-bypass/action.yml new file mode 100644 index 000000000000..2ed0b8526f91 --- /dev/null +++ b/.github/actions/check-bypass/action.yml @@ -0,0 +1,41 @@ +name: "Check bypass" +description: "A custom action to encapsulate PFCCLab/ci-bypass" +inputs: + github-token: + description: "GitHub token" + required: true + workflow-name: + description: "Workflow name" + required: true +outputs: + can-skip: + description: "Whether the workflow can be skipped." + value: ${{ steps.check-bypass.outputs.can-skip }} + +runs: + using: "composite" + steps: + - id: check-bypass + name: Check Bypass + env: + CI_TEAM_MEMBERS: '["tianshuo78520a", "swgu98", "risemeup1", "XieYunshen","luotao1","From00"]' + uses: PFCCLab/ci-bypass@v1 + with: + github-token: ${{ inputs.github-token }} + non-pull-request-event-strategy: 'never-skipped' + type: 'composite' + composite-rule: | + { + "any": [ + { + "type": "labeled", + "label": ["skip-ci: ${{ inputs.workflow-name }}", "skip-ci: all"], + "username": ${{ env.CI_TEAM_MEMBERS }} + }, + { + "type": "commented", + "comment-pattern": [".*/skip-ci ${{ inputs.workflow-name }}.*", ".*/skip-ci all.*"], + "username": ${{ env.CI_TEAM_MEMBERS }} + } + ] + } diff --git a/.github/workflows/approval.yml b/.github/workflows/approval.yml index e7e9ddb25d81..b2b69602a733 100644 --- a/.github/workflows/approval.yml +++ b/.github/workflows/approval.yml @@ -33,6 +33,14 @@ jobs: git checkout -b test_pr upstream/${BRANCH} git merge --no-edit origin_pr git log --pretty=oneline -10 + + - name: Check bypass + id: check-bypass + uses: ./.github/actions/check-bypass + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + workflow-name: approval + - name: Display Required Approvers if: steps.check-bypass.outputs.can-skip != 'true' run: | diff --git a/.github/workflows/check-bypass.yml b/.github/workflows/check-bypass.yml new file mode 100644 index 000000000000..aace1a9bbaad --- /dev/null +++ b/.github/workflows/check-bypass.yml @@ -0,0 +1,52 @@ +on: + workflow_call: + inputs: + workflow-name: + required: true + type: string + secrets: + github-token: + required: true + outputs: + can-skip: + description: "Whether the workflow can be skipped." + value: ${{ jobs.check-bypass.outputs.can-skip }} + +jobs: + check-bypass: + name: Check bypass + runs-on: + group: APPROVAL + permissions: + contents: read + env: + CI_TEAM_MEMBERS: '["tianshuo78520a", "swgu98", "risemeup1" , "XieYunshen","luotao1","From00"]' + outputs: + can-skip: ${{ steps.check-bypass.outputs.can-skip }} + steps: + - name: Cleanup + run: | + rm -rf * .[^.]* + + - id: check-bypass + name: Check Bypass + uses: PFCCLab/ci-bypass@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + non-pull-request-event-strategy: 'never-skipped' + type: 'composite' + composite-rule: | + { + "any": [ + { + "type": "labeled", + "label": ["skip-ci: ${{ inputs.workflow-name }}", "skip-ci: all"], + "username": ${{ env.CI_TEAM_MEMBERS }} + }, + { + "type": "commented", + "comment-pattern": [".*/skip-ci ${{ inputs.workflow-name }}.*", ".*/skip-ci all.*"], + "username": ${{ env.CI_TEAM_MEMBERS }} + } + ] + } diff --git a/.github/workflows/distribute-a100.yml b/.github/workflows/distribute-a100.yml index 57b669cab515..de94a626e579 100644 --- a/.github/workflows/distribute-a100.yml +++ b/.github/workflows/distribute-a100.yml @@ -37,8 +37,18 @@ defaults: shell: bash jobs: + check-bypass: + name: Check bypass + uses: ./.github/workflows/check-bypass.yml + with: + workflow-name: 'distribute-a100' + secrets: + github-token: ${{ secrets.GITHUB_TOKEN }} + distribute-a100-ci: name: distribute-a100-ci + needs: check-bypass + if: ${{ needs.check-bypass.outputs.can-skip != 'true' }} runs-on: group: Distribute steps: diff --git a/.github/workflows/distribute-v100.yml b/.github/workflows/distribute-v100.yml index f01ea5b3e12d..f7989f931c12 100644 --- a/.github/workflows/distribute-v100.yml +++ b/.github/workflows/distribute-v100.yml @@ -37,8 +37,18 @@ defaults: shell: bash jobs: + check-bypass: + name: Check bypass + uses: ./.github/workflows/check-bypass.yml + with: + workflow-name: 'distribute-v100' + secrets: + github-token: ${{ secrets.GITHUB_TOKEN }} + distribute-v100-ci: name: distribute-v100-ci + needs: check-bypass + if: ${{ needs.check-bypass.outputs.can-skip != 'true' }} runs-on: group: Auto-Parallel steps: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6c8d208a56b6..be5fb1850350 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,8 +13,18 @@ env: TASK: PaddleNLP-CI-Lint-${{ github.event.pull_request.number }} jobs: + check-bypass: + name: Check bypass + uses: ./.github/workflows/check-bypass.yml + with: + workflow-name: 'lint' + secrets: + github-token: ${{ secrets.GITHUB_TOKEN }} + Lint: name: Lint + needs: check-bypass + if: ${{ needs.check-bypass.outputs.can-skip != 'true' }} runs-on: [self-hosted, ernie-cpu] steps: - name: Run Container