From effdf37d4b1fa6c37802128a78a43e30717b7147 Mon Sep 17 00:00:00 2001 From: Shunkichi Sato <49983831+s8sato@users.noreply.github.com> Date: Wed, 21 Feb 2024 18:47:33 +0900 Subject: [PATCH] [ci]: Fix auto-labeling (#4276) Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com> --- .github/labeler.yml | 17 +++++ .github/workflows/iroha2-dev-pr-label.yml | 36 ---------- .github/workflows/iroha2-dev-pr-static.yml | 2 +- .github/workflows/iroha2-dev-pr-title.yml | 83 +++++++++++----------- .github/workflows/iroha2-dev-pr.yml | 2 +- .github/workflows/iroha2-label.yml | 21 +++--- 6 files changed, 73 insertions(+), 88 deletions(-) create mode 100644 .github/labeler.yml delete mode 100644 .github/workflows/iroha2-dev-pr-label.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000000..171c70f882d --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,17 @@ +iroha2: + - base-branch: '^iroha2.*$' + +api-changes: + - all: + - base-branch: '^iroha2-dev$' + - changed-files: + - any-glob-to-any-file: + - 'docs/source/references/schema.json' + - 'torii/src/**' + - 'torii/const/src/**' + +config-changes: + - all: + - base-branch: '^iroha2-dev$' + - changed-files: + - any-glob-to-any-file: 'configs/**' diff --git a/.github/workflows/iroha2-dev-pr-label.yml b/.github/workflows/iroha2-dev-pr-label.yml deleted file mode 100644 index 4eb18953a92..00000000000 --- a/.github/workflows/iroha2-dev-pr-label.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: I2::Dev::Label - -on: - pull_request: - branches: [iroha-dev] - paths: - - 'docs/source/references/schema.json' - -jobs: - api-changes: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: jitterbit/get-changed-files@v1 - continue-on-error: true - id: api_label - - uses: actions-ecosystem/action-add-labels@v1 - if: contains(steps.api_label.outputs.added_modified, 'docs/source/references/schema.json') - with: - github_token: ${{ secrets.github_token }} - labels: | - api-changes - - config-changes: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: jitterbit/get-changed-files@v1 - continue-on-error: true - id: config_label - - uses: actions-ecosystem/action-add-labels@v1 - if: contains(steps.config_label.outputs.added_modified) - with: - github_token: ${{ secrets.github_token }} - labels: | - config-changes diff --git a/.github/workflows/iroha2-dev-pr-static.yml b/.github/workflows/iroha2-dev-pr-static.yml index 59439db45f9..f2bcdb1e423 100644 --- a/.github/workflows/iroha2-dev-pr-static.yml +++ b/.github/workflows/iroha2-dev-pr-static.yml @@ -7,7 +7,7 @@ on: - '**.rs' - '**.json' - '**.toml' - - '.github/workflows/**.yml' + - '.github/workflows/iroha2-dev-pr-static.yml' - 'client_cli/pytests/**/*.py' concurrency: diff --git a/.github/workflows/iroha2-dev-pr-title.yml b/.github/workflows/iroha2-dev-pr-title.yml index 5c6de6285bc..2c698821abc 100644 --- a/.github/workflows/iroha2-dev-pr-title.yml +++ b/.github/workflows/iroha2-dev-pr-title.yml @@ -1,14 +1,13 @@ name: I2::Dev::Title on: - pull_request: + pull_request_target: branches: [iroha2-dev] types: [opened, edited, reopened] jobs: check: runs-on: ubuntu-latest - # TODO: Add labels when https://github.com/actions/first-interaction/issues/10 is fixed. steps: - name: Feature uses: actions-ecosystem/action-regex-match@v2 @@ -16,14 +15,14 @@ jobs: with: text: ${{ github.event.pull_request.title }} regex: '^\[feature\] #\d+(, #\d+)*: .+$' - # - name: Add feature label - # uses: actions-ecosystem/action-add-labels@v1 - # if: steps.feature-match.outputs.match != '' - # continue-on-error: true - # with: - # github_token: ${{ secrets.github_token }} - # labels: | - # Enhancement + - name: Add feature label + uses: actions-ecosystem/action-add-labels@v1 + if: steps.feature-match.outputs.match != '' + continue-on-error: true + with: + github_token: ${{ secrets.github_token }} + labels: | + Enhancement - name: Refactor uses: actions-ecosystem/action-regex-match@v2 @@ -32,14 +31,14 @@ jobs: with: text: ${{ github.event.pull_request.title }} regex: '^\[refactor\]( #\d+(, #\d+)*)?: .+$' - # - name: Add Refactor label - # uses: actions-ecosystem/action-add-labels@v1 - # if: steps.refactor-match.outputs.match != '' - # continue-on-error: true - # with: - # github_token: ${{ secrets.github_token }} - # labels: | - # Refactor + - name: Add Refactor label + uses: actions-ecosystem/action-add-labels@v1 + if: steps.refactor-match.outputs.match != '' + continue-on-error: true + with: + github_token: ${{ secrets.github_token }} + labels: | + Refactor - name: Fix uses: actions-ecosystem/action-regex-match@v2 @@ -48,14 +47,14 @@ jobs: with: text: ${{ github.event.pull_request.title }} regex: '\[fix\] #\d+(, #\d+)*: .+$' - # - name: Add fix label - # uses: actions-ecosystem/action-add-labels@v1 - # if: steps.fix-match.outputs.match != '' - # continue-on-error: true - # with: - # github_token: ${{ secrets.github_token }} - # labels: | - # Bug + - name: Add fix label + uses: actions-ecosystem/action-add-labels@v1 + if: steps.fix-match.outputs.match != '' + continue-on-error: true + with: + github_token: ${{ secrets.github_token }} + labels: | + Bug - name: Documentation uses: actions-ecosystem/action-regex-match@v2 @@ -64,14 +63,14 @@ jobs: with: text: ${{ github.event.pull_request.title }} regex: '^\[documentation\]( #\d+(, #\d+)*)?: .+$' - # - name: Add Documentation label - # uses: actions-ecosystem/action-add-labels@v1 - # if: steps.docs-match.outputs.match != '' - # continue-on-error: true - # with: - # github_token: ${{ secrets.github_token }} - # labels: | - # Documentation + - name: Add Documentation label + uses: actions-ecosystem/action-add-labels@v1 + if: steps.docs-match.outputs.match != '' + continue-on-error: true + with: + github_token: ${{ secrets.github_token }} + labels: | + Documentation - name: CI uses: actions-ecosystem/action-regex-match@v2 @@ -80,14 +79,14 @@ jobs: with: text: ${{ github.event.pull_request.title }} regex: '^\[ci\]( #\d+(, #\d+)*)?: .+$' - # - name: Add CI label - # uses: actions-ecosystem/action-add-labels@v1 - # if: steps.ci-match.outputs.match != '' - # continue-on-error: true - # with: - # github_token: ${{ secrets.github_token }} - # labels: | - # CI + - name: Add CI label + uses: actions-ecosystem/action-add-labels@v1 + if: steps.ci-match.outputs.match != '' + continue-on-error: true + with: + github_token: ${{ secrets.github_token }} + labels: | + CI - name: None of the above if: steps.fix-match.outputs.match == '' && steps.refactor-match.outputs.match == '' && steps.feature-match.outputs.match == '' && steps.docs-match.outputs.match == '' && steps.ci-match.outputs.match == '' diff --git a/.github/workflows/iroha2-dev-pr.yml b/.github/workflows/iroha2-dev-pr.yml index 9bb38c02a2b..ee2fab3d43a 100644 --- a/.github/workflows/iroha2-dev-pr.yml +++ b/.github/workflows/iroha2-dev-pr.yml @@ -7,7 +7,7 @@ on: - '**.rs' - '**.json' - '**.toml' - - '.github/workflows/**.yml' + - '.github/workflows/iroha2-dev-pr.yml' concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/iroha2-label.yml b/.github/workflows/iroha2-label.yml index d538c592cbb..0e5608287e3 100644 --- a/.github/workflows/iroha2-label.yml +++ b/.github/workflows/iroha2-label.yml @@ -2,15 +2,20 @@ name: I2::Label on: pull_request_target: - branches: [iroha2-dev, iroha2-stable, iroha2-lts] - types: [opened] jobs: - add: + labeler: + permissions: + contents: read + pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions-ecosystem/action-add-labels@v1 - with: - github_token: ${{ secrets.github_token }} - labels: | - iroha2 + - id: label-the-PR + uses: actions/labeler@v5 + with: + sync-labels: true + - uses: mshick/add-pr-comment@v2 + if: contains(steps.label-the-PR.outputs.all-labels, 'config-changes') + with: + message: | + @BAStos525