[hotfix] Improve CI trigger and cancel strategy (#42)

Signed-off-by: tison <wander4096@gmail.com>
diff --git a/.github/workflows/push_pr.yml b/.github/workflows/ci.yml
similarity index 62%
rename from .github/workflows/push_pr.yml
rename to .github/workflows/ci.yml
index 6d7b36c..01b5245 100644
--- a/.github/workflows/push_pr.yml
+++ b/.github/workflows/ci.yml
@@ -17,14 +17,33 @@
 ################################################################################
 
 name: CI
-on: [push, pull_request]
+on:
+  push:
+    branches:
+      - 'main'
+      - 'v*'
+  pull_request:
+    branches:
+      - 'main'
+      - 'v*'
+
+# Concurrency strategy:
+#   github.workflow: distinguish this workflow from others
+#   github.event_name: distinguish `push` event from `pull_request` event
+#   github.event.number: set to the number of the pull request if `pull_request` event
+#   github.run_id: otherwise, it's a `push` or `schedule` event, only cancel if we rerun the workflow
+#
+# Reference:
+#   https://docs.github.com/en/actions/using-jobs/using-concurrency
+#   https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
 concurrency:
-  group: ${{ github.workflow }}-${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }}
   cancel-in-progress: true
+
 jobs:
   compile_and_test:
     uses: apache/flink-connector-shared-utils/.github/workflows/ci.yml@ci_utils
     with:
       flink_version: 1.17.0
       timeout_global: 80
-      timeout_test: 60
\ No newline at end of file
+      timeout_test: 60