You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2024/02/08 06:24:48 UTC

(superset) 01/01: feat(actions): auto-label PRs that close issues.

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

rusackas pushed a commit to branch label-issue-closing-PRs
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 268fe95f839e74c6a012f7f990d75d376106eb1b
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Wed Feb 7 23:24:38 2024 -0700

    feat(actions): auto-label PRs that close issues.
---
 .github/workflows/labeler.yml | 45 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
index 15a41995d1..7590c99d9b 100644
--- a/.github/workflows/labeler.yml
+++ b/.github/workflows/labeler.yml
@@ -1,8 +1,28 @@
 name: "Pull Request Labeler"
 on:
-- pull_request_target
+  pull_request_target:
+    types: [opened, reopened, synchronize]
+
+# cancel previous workflow jobs for PRs
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
+  cancel-in-progress: true
+  
 
 jobs:
+  config:
+    runs-on: "ubuntu-latest"
+    outputs:
+      has-secrets: ${{ steps.check.outputs.has-secrets }}
+    steps:
+      - name: "Check for secrets"
+        id: check
+        shell: bash
+        run: |
+          if [ -n "${{ (secrets.GITHUB_TOKEN != '') || '' }}" ]; then
+            echo "has-secrets=1" >> "$GITHUB_OUTPUT"
+          fi
+
   labeler:
     permissions:
       contents: read
@@ -19,3 +39,26 @@ jobs:
     #   run: |
     #     echo "Running translation scripts"
     #     # Generate .pot -> .po -> .json files
+
+  label-auto-closing:
+    needs: config
+    if: needs.config.outputs.has-secrets
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: Auto-label PRs
+      uses: actions/github-script@v7
+      with:
+        github-token: ${{secrets.GITHUB_TOKEN}}
+        script: |
+          const closingKeywords = /close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved #[0-9]+/gi;
+          const prBody = context.payload.pull_request.body;
+          const issueNumbers = prBody.match(closingKeywords);
+          if (issueNumbers) {
+            github.issues.addLabels({
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              issue_number: context.issue.number,
+              labels: ['closes-issue']
+            });
+          }
\ No newline at end of file