This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts-bot.git


The following commit(s) were added to refs/heads/master by this push:
     new 8f9d9fb  feat: auto delete update-notice-year branch created by bot
8f9d9fb is described below

commit 8f9d9fb0e3b5eafd4a060722a0939a67c51e64f4
Author: plainheart <y...@all-my-life.cn>
AuthorDate: Sun Dec 31 18:14:10 2023 +0800

    feat: auto delete update-notice-year branch created by bot
---
 index.js | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/index.js b/index.js
index 6abe430..e13a91e 100644
--- a/index.js
+++ b/index.js
@@ -275,11 +275,20 @@ module.exports = (/** @type {Probot} */ app) => {
                 labelText.PR_AWAITING_REVIEW
             ])
         ];
-        const isMerged = context.payload.pull_request.merged;
-        if (isMerged) {
+        const pr = context.payload.pull_request;
+        if (pr.merged) {
             actions.push(commentIssue(context, text.PR_MERGED));
         }
-        return Promise.all(actions);
+        // delete created branch by bot
+        if (pr.head.ref.includes('update-notice-year') && pr.user.type == 
'Bot') {
+            const deleteBranch = context.octokit.git.deleteRef(
+                context.repo({
+                    ref: 'heads/' + pr.head.ref
+                })
+            );
+            actions.push(deleteBranch);
+        }
+        return Promise.allSettled(actions);
     });
 
     app.on(['pull_request_review.submitted'], async context => {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org
For additional commands, e-mail: commits-h...@echarts.apache.org

Reply via email to