From 1767200120172b0b224b4b2c4ffd49a2f9039cbd Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Wed, 13 Sep 2023 15:07:18 +0700 Subject: [PATCH 1/7] fix: event trigger label conflict --- .github/workflows/label-conflict.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/label-conflict.yml b/.github/workflows/label-conflict.yml index 0030dd06bede..6aa2e3d14e95 100644 --- a/.github/workflows/label-conflict.yml +++ b/.github/workflows/label-conflict.yml @@ -1,9 +1,5 @@ name: Auto Label Conflicts -on: - pull_request: - branches: - - 'develop' - - '4.*' +on: pull_request_target concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -15,13 +11,13 @@ permissions: pull-requests: write jobs: - auto-label: + auto-label-conflict: runs-on: ubuntu-latest steps: - uses: prince-chrismc/label-merge-conflicts-action@v3 with: conflict_label_name: 'stale' - github_token: ${{ github.token }} + github_token: ${{ secrets.GITHUB_TOKEN }} # --- Optional Inputs --- # To make sure the merge commit exactly matches the branch From 933047354285c338216b3ac2fe2fadad95cdc6ea Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Wed, 13 Sep 2023 16:34:23 +0700 Subject: [PATCH 2/7] fix: labeling manually but commenting with automation --- .github/workflows/label-conflict.yml | 30 ++++++++++++---------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/label-conflict.yml b/.github/workflows/label-conflict.yml index 6aa2e3d14e95..4c8168e7566f 100644 --- a/.github/workflows/label-conflict.yml +++ b/.github/workflows/label-conflict.yml @@ -1,31 +1,27 @@ name: Auto Label Conflicts -on: pull_request_target +on: + pull_request: + branches: + - 'develop' + - '4.*' concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true -permissions: - contents: read - issues: write - pull-requests: write - jobs: auto-label-conflict: + if: github.event.label.name == 'stale' runs-on: ubuntu-latest + permissions: + pull-requests: write steps: - - uses: prince-chrismc/label-merge-conflicts-action@v3 + - name: Add comment for PR with conflict + uses: peter-evans/create-or-update-comment@v3 with: - conflict_label_name: 'stale' - github_token: ${{ secrets.GITHUB_TOKEN }} - - # --- Optional Inputs --- - # To make sure the merge commit exactly matches the branch - detect_merge_changes: true # or true to handle as conflicts - # By default a comment will be left, adding `conflict_comment: ''` will disable comments - # The optional `${author}` will be replaced with the username of the pull request - conflict_comment: | - :wave: Hi, @${author}, + issue-number: ${{ github.event.pull_request.number }} + body: | + :wave: Hi, We detected conflicts in your PR against the base branch :speak_no_evil: You may want to sync :arrows_counterclockwise: your branch with upstream! From 6403574209f4aefad0f7fcc007bb568a52153e81 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Wed, 13 Sep 2023 16:35:00 +0700 Subject: [PATCH 3/7] fix: labeling manually but commenting with automation --- .github/workflows/label-conflict.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/label-conflict.yml b/.github/workflows/label-conflict.yml index 4c8168e7566f..b4349123039e 100644 --- a/.github/workflows/label-conflict.yml +++ b/.github/workflows/label-conflict.yml @@ -4,6 +4,8 @@ on: branches: - 'develop' - '4.*' + types: + - labeled concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} From 209e4bbc2256012bc0f81d20c6bbc6f1bd9c455d Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Fri, 15 Sep 2023 10:53:28 +0700 Subject: [PATCH 4/7] added user login to message --- .github/workflows/label-conflict.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/label-conflict.yml b/.github/workflows/label-conflict.yml index b4349123039e..e93280eaef5f 100644 --- a/.github/workflows/label-conflict.yml +++ b/.github/workflows/label-conflict.yml @@ -1,4 +1,4 @@ -name: Auto Label Conflicts +name: Auto Comment Conflicts on: pull_request: branches: @@ -12,7 +12,7 @@ concurrency: cancel-in-progress: true jobs: - auto-label-conflict: + auto-comment-conflict: if: github.event.label.name == 'stale' runs-on: ubuntu-latest permissions: @@ -23,7 +23,7 @@ jobs: with: issue-number: ${{ github.event.pull_request.number }} body: | - :wave: Hi, + :wave: Hi, @${{ github.event.pull_request.user.login }}! We detected conflicts in your PR against the base branch :speak_no_evil: You may want to sync :arrows_counterclockwise: your branch with upstream! From 0f563a3d58f87b65e7d02bb276bf11e2b7e7ed9c Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Fri, 15 Sep 2023 11:10:27 +0700 Subject: [PATCH 5/7] add token --- .github/workflows/label-conflict.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/label-conflict.yml b/.github/workflows/label-conflict.yml index e93280eaef5f..5d3d7c5513f2 100644 --- a/.github/workflows/label-conflict.yml +++ b/.github/workflows/label-conflict.yml @@ -21,6 +21,7 @@ jobs: - name: Add comment for PR with conflict uses: peter-evans/create-or-update-comment@v3 with: + token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.pull_request.number }} body: | :wave: Hi, @${{ github.event.pull_request.user.login }}! From fbe374ac167b43ef7408c089302d714a23c1a129 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Fri, 15 Sep 2023 11:29:35 +0700 Subject: [PATCH 6/7] permission jobs --- .github/workflows/label-conflict.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/label-conflict.yml b/.github/workflows/label-conflict.yml index 5d3d7c5513f2..03e68e77d099 100644 --- a/.github/workflows/label-conflict.yml +++ b/.github/workflows/label-conflict.yml @@ -16,6 +16,7 @@ jobs: if: github.event.label.name == 'stale' runs-on: ubuntu-latest permissions: + contents: read pull-requests: write steps: - name: Add comment for PR with conflict From 521c50a041bcc3502995fd11b093b0e97e93f4e4 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean Date: Fri, 15 Sep 2023 11:47:42 +0700 Subject: [PATCH 7/7] ordering permission --- .github/workflows/label-conflict.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/label-conflict.yml b/.github/workflows/label-conflict.yml index 03e68e77d099..363cb967d274 100644 --- a/.github/workflows/label-conflict.yml +++ b/.github/workflows/label-conflict.yml @@ -13,11 +13,11 @@ concurrency: jobs: auto-comment-conflict: - if: github.event.label.name == 'stale' - runs-on: ubuntu-latest permissions: contents: read pull-requests: write + if: github.event.label.name == 'stale' + runs-on: ubuntu-latest steps: - name: Add comment for PR with conflict uses: peter-evans/create-or-update-comment@v3