From 3f641e3bb5d368eee2670b73390870750365fa03 Mon Sep 17 00:00:00 2001 From: "Alex.hxy" <1872591453@qq.com> Date: Thu, 14 Nov 2024 17:50:06 +0800 Subject: [PATCH 1/3] chore: ci optimization --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06ce6464ee..958dcf0e45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,12 +5,15 @@ on: branches: - next - V3.0 + pull_request: + types: [opened, synchronize, reopened] pull_request_target: types: [opened, synchronize, reopened] workflow_dispatch: jobs: lint: + if: ${{ github.event_name == 'pull_request' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -30,6 +33,7 @@ jobs: run: npm run lint test: + if: ${{ github.event_name == 'pull_request' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -55,6 +59,7 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} build: + if: ${{ github.event_name == 'pull_request' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -83,6 +88,7 @@ jobs: if: github.ref == 'refs/heads/next' run: npm run build:taro:site add-label: + if: ${{ github.event_name == 'pull_request_target' }} runs-on: ubuntu-latest steps: From c88fcb4ddd0cd7a27dbacf716bdce1f7baaf6e82 Mon Sep 17 00:00:00 2001 From: "Alex.hxy" <1872591453@qq.com> Date: Thu, 14 Nov 2024 18:14:42 +0800 Subject: [PATCH 2/3] chore: save --- .github/workflows/add-label.yml | 33 +++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 31 ------------------------------- 2 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/add-label.yml diff --git a/.github/workflows/add-label.yml b/.github/workflows/add-label.yml new file mode 100644 index 0000000000..0f7f6e7942 --- /dev/null +++ b/.github/workflows/add-label.yml @@ -0,0 +1,33 @@ +name: Add Label + +on: + pull_request_target: + types: [opened, synchronize, reopened] + workflow_dispatch: + +jobs: + add-label: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Determine label based on target branch + id: determine-label + run: | + echo "${{github.event_name}}" + if [[ "${{ github.event.pull_request.base.ref }}" == "next" ]]; then + echo "label=2.x" >> $GITHUB_ENV + elif [[ "${{ github.event.pull_request.base.ref }}" == "V3.0" ]]; then + echo "label=3.x" >> $GITHUB_ENV + else + echo "label=" >> $GITHUB_ENV + fi + + - name: Add label to Pull Request + if: env.label != '' + uses: actions-ecosystem/action-add-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: ${{ env.label }} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 958dcf0e45..5368de3288 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,13 +7,10 @@ on: - V3.0 pull_request: types: [opened, synchronize, reopened] - pull_request_target: - types: [opened, synchronize, reopened] workflow_dispatch: jobs: lint: - if: ${{ github.event_name == 'pull_request' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -33,7 +30,6 @@ jobs: run: npm run lint test: - if: ${{ github.event_name == 'pull_request' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -59,7 +55,6 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} build: - if: ${{ github.event_name == 'pull_request' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -87,29 +82,3 @@ jobs: - name: Build NutUI-React Taro H5 Demo if: github.ref == 'refs/heads/next' run: npm run build:taro:site - add-label: - if: ${{ github.event_name == 'pull_request_target' }} - runs-on: ubuntu-latest - - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Determine label based on target branch - id: determine-label - run: | - echo "${{github.event_name}}" - if [[ "${{ github.event.pull_request.base.ref }}" == "next" ]]; then - echo "label=2.x" >> $GITHUB_ENV - elif [[ "${{ github.event.pull_request.base.ref }}" == "V3.0" ]]; then - echo "label=3.x" >> $GITHUB_ENV - else - echo "label=" >> $GITHUB_ENV - fi - - - name: Add label to Pull Request - if: env.label != '' - uses: actions-ecosystem/action-add-labels@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - labels: ${{ env.label }} \ No newline at end of file From 10a48345f1460ef481ced94689bc4703a164d8a7 Mon Sep 17 00:00:00 2001 From: "Alex.hxy" <1872591453@qq.com> Date: Thu, 14 Nov 2024 18:18:05 +0800 Subject: [PATCH 3/3] chore: save --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5368de3288..dd3035c323 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,4 +81,4 @@ jobs: - name: Build NutUI-React Taro H5 Demo if: github.ref == 'refs/heads/next' - run: npm run build:taro:site + run: npm run build:taro:site \ No newline at end of file