浏览代码

github: react to PR/issue comments [skip ci]

``/notstale`` will remove ``stale`` label
``/notexpired`` will change the status to ``open``

> https://github.com/marketplace/actions/github-script
Victor Seva 1 年之前
父节点
当前提交
026e90350d
共有 1 个文件被更改,包括 38 次插入0 次删除
  1. 38 0
      .github/workflows/labels.yml

+ 38 - 0
.github/workflows/labels.yml

@@ -0,0 +1,38 @@
+name: manage labels from comments
+
+on: [issue_comment]
+
+jobs:
+  manage:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/github-script@v7
+        if: ${{ contains(github.event.comment.body, '/notstale') }}
+        with:
+          script: |
+            github.rest.issues.removeLabel({
+              context.repo.owner,
+              context.repo.repo,
+              context.issue.number,
+              name,
+            });
+      - uses: actions/github-script@v7
+        if: ${{ !github.event.issue.pull_request && contains(github.event.comment.body, '/notexpired') }}
+        with:
+          script: |
+            github.rest.issues.update({
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              issue_number: context.issue.number,
+              state: "open",
+            });
+      - uses: actions/github-script@v7
+        if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/notexpired') }}
+        with:
+          script: |
+            github.rest.pulls.update({
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              pull_number: context.issue.number,
+              state: "open",
+            });