From a117a30c0c5b89af9c7c45142eb08d41fc1e4c44 Mon Sep 17 00:00:00 2001 From: mxsm Date: Fri, 14 Jun 2024 15:52:45 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[ISSUE=20#541]=F0=9F=94=A8Add=20Auto-Merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/automerge.yml | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/automerge.yml diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000..2b8c4e83 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,47 @@ +name: PR auto merge +on: + pull_request: + types: + - labeled + - unlabeled + - synchronize + - opened + - edited + - ready_for_review + - reopened + - unlocked + pull_request_review: + types: + - submitted + check_suite: + types: + - completed +jobs: + automerge: + runs-on: ubuntu-latest + steps: + - name: automerge + uses: "pascalgn/automerge-action@v0.16.3" + env: + GITHUB_TOKEN: "${{ secrets.PAT_TOKEN }}" + MERGE_LABELS: "auto merge" + MERGE_REMOVE_LABELS: "auto merge" + MERGE_METHOD: "squash" + MERGE_COMMIT_MESSAGE: "๐Ÿš€This PR has been automatically merged with squash.๐ŸŽ‰" + MERGE_FORKS: "false" + MERGE_RETRIES: "6" + MERGE_RETRY_SLEEP: "10000" + MERGE_REQUIRED_APPROVALS: "0" + UPDATE_METHOD: "rebase" + + - name: Add comment + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.PAT_TOKEN }} + script: | + github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: "๐Ÿš€This PR has been automatically merged with squash.๐Ÿš€" + }) \ No newline at end of file From c00ea914031ede0e133c7f7615982e574366aedb Mon Sep 17 00:00:00 2001 From: mxsm Date: Fri, 14 Jun 2024 16:02:47 +0800 Subject: [PATCH 2/4] fix error --- .github/workflows/automerge.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 2b8c4e83..85c68a03 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -39,9 +39,10 @@ jobs: with: github-token: ${{ secrets.PAT_TOKEN }} script: | + const { owner, repo, number: issue_number } = context.issue; github.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.pull_request.number, + owner, + repo, + issue_number, body: "๐Ÿš€This PR has been automatically merged with squash.๐Ÿš€" }) \ No newline at end of file From 0a81e7c309ccd921580654912a628a8f39e7f7df Mon Sep 17 00:00:00 2001 From: mxsm Date: Fri, 14 Jun 2024 16:04:44 +0800 Subject: [PATCH 3/4] fix ci --- .github/workflows/automerge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 85c68a03..721ca859 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -40,7 +40,7 @@ jobs: github-token: ${{ secrets.PAT_TOKEN }} script: | const { owner, repo, number: issue_number } = context.issue; - github.issues.createComment({ + github.rest.issues.createComment({ owner, repo, issue_number, From fe26346958fc8d29e34e8676bd60b5e6980da4b6 Mon Sep 17 00:00:00 2001 From: mxsm Date: Fri, 14 Jun 2024 16:11:47 +0800 Subject: [PATCH 4/4] fix ci error --- .github/workflows/automerge.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 721ca859..ff65a9c5 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -1,21 +1,11 @@ -name: PR auto merge +name: Auto Merge PR on: pull_request: types: - labeled - - unlabeled - synchronize - opened - - edited - - ready_for_review - - reopened - - unlocked - pull_request_review: - types: - - submitted - check_suite: - types: - - completed + jobs: automerge: runs-on: ubuntu-latest @@ -35,6 +25,7 @@ jobs: UPDATE_METHOD: "rebase" - name: Add comment + if: success() && steps.automerge.outputs.merged == 'true' uses: actions/github-script@v7 with: github-token: ${{ secrets.PAT_TOKEN }}