You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by he...@apache.org on 2022/06/15 06:21:14 UTC

[incubator-inlong] branch master updated: [INLONG-4636][CI] Add check PR title workflow (#4637)

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

healchow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 2398ac06f [INLONG-4636][CI] Add check PR title workflow (#4637)
2398ac06f is described below

commit 2398ac06fad5e42d209e9e1236791de5497f22fe
Author: Yuanhao Ji <ji...@apache.org>
AuthorDate: Wed Jun 15 14:21:08 2022 +0800

    [INLONG-4636][CI] Add check PR title workflow (#4637)
---
 .github/workflows/README.md             | 10 ++++++
 .github/workflows/ci_check_pr_title.yml | 56 +++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+)

diff --git a/.github/workflows/README.md b/.github/workflows/README.md
index d414073ce..89531bb04 100644
--- a/.github/workflows/README.md
+++ b/.github/workflows/README.md
@@ -50,6 +50,16 @@ This directory contains all InLong CI checks.
 
   Interact with newcomers using the [actions/first-interaction](https://github.com/actions/first-interaction) action.
 
+- [![InLong Check Pull Request Title](https://github.com/apache/incubator-inlong/actions/workflows/ci_check_pr_title.yml/badge.svg)](https://github.com/apache/incubator-inlong/actions/workflows/ci_check_pr_title.yml)
+
+  Check pull request title.
+
+  Title Example: `[INLONG-XYZ][Component] Title of the pull request`
+  
+  > - **XYZ** should be replaced by the actual [GitHub Issue](https://github.com/apache/incubator-inlong/issues) number, e.g. `[INLONG-123]`
+  >
+  > - **Component** should be replaced by the InLong component name, e.g. `[INLONG-123][Manager]`
+
 ### Troubleshooting
 
 If you have any questions, welcome to contact the maintainers. And feel free to make a [pull request](https://github.com/apache/incubator-inlong/compare)!
diff --git a/.github/workflows/ci_check_pr_title.yml b/.github/workflows/ci_check_pr_title.yml
new file mode 100644
index 000000000..5dae9f40a
--- /dev/null
+++ b/.github/workflows/ci_check_pr_title.yml
@@ -0,0 +1,56 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+name: InLong Check Pull Request Title
+
+on:
+  pull_request_target:
+    types:
+      - opened
+      - reopened
+      - edited
+      - synchronize
+
+jobs:
+  check:
+    name: Check pull request title
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+
+      # The correct title should start with [WIP] or [INLONG-xxx],
+      # where xxx is the issue number, e.g. [INLONG-123].
+      - name: Check title
+        if: ${{ github.event_name == 'pull_request_target' }}
+        run: |
+          if [[ ! "$PR_TITLE" =~ ^\[(WIP|INLONG-[0-9]+)\]\[[a-zA-Z]+\].*$ ]]; then
+            echo "This pull request title is not valid."
+            echo "Title Example: [INLONG-XYZ][Component] Title of the pull request"
+            echo "XYZ should be replaced by the actual GitHub Issue number, e.g. [INLONG-123]"
+            echo "Component should be replaced by the InLong component name, e.g. [INLONG-123][Manager]"
+          
+            # add a job summary
+            echo "## This pull request title is not valid! :bug:" >> $GITHUB_STEP_SUMMARY
+            echo "Title Example: \`[INLONG-XYZ][Component] Title of the pull request\`" >> $GITHUB_STEP_SUMMARY
+            echo "> - **XYZ** should be replaced by the actual [GitHub Issue](https://github.com/apache/incubator-inlong/issues) number, e.g. \`[INLONG-123]\`" >> $GITHUB_STEP_SUMMARY
+            echo "> - **Component** should be replaced by the InLong component name, e.g. \`[INLONG-123][Manager]\`" >> $GITHUB_STEP_SUMMARY
+
+            exit 1
+          fi
+        env:
+          PR_TITLE: ${{ github.event.pull_request.title }}