From 2d1db2d46547e02cf57d04d8c2225208c550448f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=BCnther?= Date: Sun, 19 Feb 2023 20:49:38 +0100 Subject: [PATCH 1/5] TASK: Adding labels to PRs With this task, we add automatically labels to the PRs. That makes the maintaining easier, as we did that manually all the time. We always add the target branch as label, so we see directly which version the PR targets. And if the Commit message is following our rules, we als add the bugfix, task or feature label. --- .github/workflows/add-pr-labels.yml | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/add-pr-labels.yml diff --git a/.github/workflows/add-pr-labels.yml b/.github/workflows/add-pr-labels.yml new file mode 100644 index 0000000000..3a1eac6cdc --- /dev/null +++ b/.github/workflows/add-pr-labels.yml @@ -0,0 +1,31 @@ +name: Add Labels to Pull Request + +on: + pull_request: + types: [opened, reopened] + +jobs: + add-labels: + runs-on: ubuntu-latest + steps: + - name: Add target branch label + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: ${{ github.event.pull_request.base.ref }} + - name: Add feature label + if: startsWith(github.event.pull_request.title, 'FEATURE:') + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: 'feature' + - name: Add bugfix label + if: startsWith(github.event.pull_request.title, 'BUGFIX:') + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: 'bugfix' + - name: Add task label + if: startsWith(github.event.pull_request.title, 'TASK:') + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: 'task' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 22d6d309daec9423944728b408e34cb202fb07aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=BCnther?= Date: Sun, 19 Feb 2023 21:27:27 +0100 Subject: [PATCH 2/5] TASK: Remove label if target has changed --- .github/workflows/add-pr-labels.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/add-pr-labels.yml b/.github/workflows/add-pr-labels.yml index 3a1eac6cdc..6782876d6c 100644 --- a/.github/workflows/add-pr-labels.yml +++ b/.github/workflows/add-pr-labels.yml @@ -2,16 +2,18 @@ name: Add Labels to Pull Request on: pull_request: - types: [opened, reopened] + types: [opened, reopened, synchronize] jobs: add-labels: runs-on: ubuntu-latest steps: - - name: Add target branch label - uses: actions-ecosystem/action-add-labels@v1 + - name: Checkout + uses: actions/checkout@v2 + - name: Remove all labels + uses: rogerluan/label-remover@v1.0.1 with: - labels: ${{ github.event.pull_request.base.ref }} + github_token: ${{ secrets.GITHUB_TOKEN }} - name: Add feature label if: startsWith(github.event.pull_request.title, 'FEATURE:') uses: actions-ecosystem/action-add-labels@v1 @@ -27,5 +29,9 @@ jobs: uses: actions-ecosystem/action-add-labels@v1 with: labels: 'task' + - name: Add target branch label + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: ${{ github.base_ref }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 689b4256eca63c30e302a251f9f2240b8db8217c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=BCnther?= Date: Sun, 19 Feb 2023 22:36:43 +0100 Subject: [PATCH 3/5] TASK: Apply the correct labels --- .github/workflows/add-pr-labels.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/add-pr-labels.yml b/.github/workflows/add-pr-labels.yml index 6782876d6c..2eec0bb9c0 100644 --- a/.github/workflows/add-pr-labels.yml +++ b/.github/workflows/add-pr-labels.yml @@ -18,17 +18,17 @@ jobs: if: startsWith(github.event.pull_request.title, 'FEATURE:') uses: actions-ecosystem/action-add-labels@v1 with: - labels: 'feature' + labels: 'Feature' - name: Add bugfix label if: startsWith(github.event.pull_request.title, 'BUGFIX:') uses: actions-ecosystem/action-add-labels@v1 with: - labels: 'bugfix' + labels: 'Bug' - name: Add task label if: startsWith(github.event.pull_request.title, 'TASK:') uses: actions-ecosystem/action-add-labels@v1 with: - labels: 'task' + labels: 'Task' - name: Add target branch label uses: actions-ecosystem/action-add-labels@v1 with: From 0de15870768e08e49c8ba2b6adb1153c3aca3f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=BCnther?= Date: Sun, 19 Feb 2023 22:39:36 +0100 Subject: [PATCH 4/5] TASK: Also trigger on edited PRs --- .github/workflows/add-pr-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/add-pr-labels.yml b/.github/workflows/add-pr-labels.yml index 2eec0bb9c0..5cf65ca046 100644 --- a/.github/workflows/add-pr-labels.yml +++ b/.github/workflows/add-pr-labels.yml @@ -2,7 +2,7 @@ name: Add Labels to Pull Request on: pull_request: - types: [opened, reopened, synchronize] + types: [opened, reopened, synchronize, edited] jobs: add-labels: From 6c9ca3b8c28ff754c0ca9579c4bc434766026e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=BCnther?= Date: Mon, 20 Feb 2023 11:31:52 +0100 Subject: [PATCH 5/5] TASK: Remove only the old base branch label --- .github/workflows/add-pr-labels.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/add-pr-labels.yml b/.github/workflows/add-pr-labels.yml index 5cf65ca046..51fba7b60c 100644 --- a/.github/workflows/add-pr-labels.yml +++ b/.github/workflows/add-pr-labels.yml @@ -10,10 +10,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: Remove all labels - uses: rogerluan/label-remover@v1.0.1 + - name: Maybe remove base branch label + if: github.event.action == 'edited' && github.event.changes.base.ref.from != '' + uses: actions-ecosystem/action-remove-labels@v1 with: - github_token: ${{ secrets.GITHUB_TOKEN }} + labels: ${{ github.event.changes.base.ref.from }} - name: Add feature label if: startsWith(github.event.pull_request.title, 'FEATURE:') uses: actions-ecosystem/action-add-labels@v1