arthur-tf-sync-repos.yaml: update script

Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: I339c0d853ce9ebdb39b826ef89275d46c21c11e9
diff --git a/arthur-tf-sync-repos.yaml b/arthur-tf-sync-repos.yaml
index 69488fa..c714731 100644
--- a/arthur-tf-sync-repos.yaml
+++ b/arthur-tf-sync-repos.yaml
@@ -37,7 +37,7 @@
             branch-pattern: branch-1
 #     Trigger on tag creatation
           - branch-compare-type: REG_EXP
-            branch-pattern: refs/tags/tag-.*
+            branch-pattern: refs/tags/.*
         silent-start: true
         skip-vote:
             successful: true
diff --git a/ci/tf-sync-repos.sh b/ci/tf-sync-repos.sh
index 0450660..59e7512 100755
--- a/ci/tf-sync-repos.sh
+++ b/ci/tf-sync-repos.sh
@@ -80,11 +80,18 @@
     gerrit_branch=$(echo ${branch} | awk -F: '{print $1}')
     gh_branch=$(echo ${branch} | awk -F: '{print $2}')
 
-    # Only sync up the branch that triggered the job
-    [ "${gerrit_branch}" != "${GERRIT_REFNAME}" ] && continue
+    # Only sync up the branch that triggered the job or new tag creatation
+    if $(echo ${GERRIT_REFNAME}|grep -q "refs\/tags"); then
+        new_tag=1
+    elif [ "${gerrit_branch}" != "${GERRIT_REFNAME}" ]; then
+        continue
+    fi
 
     echo -e "\nFetching Gerrit ${GERRIT_PROJECT}:${gerrit_branch}\n"
     git -C "${_workdir}" fetch --tags "${gerrit_repo}" "${gerrit_branch}"
     echo -e "\nSyncing up to GitHub ${gh_repo}:${gh_branch}\n"
     git -C "${_workdir}" push --force --tags "${gh_remote}" FETCH_HEAD:refs/heads/"${gh_branch}"
+
+    # Triggered by new tag, no need to loop other branches
+    [ "$new_tag" == "1" ] && break
 done