Add synchronize repos workflow
authorgithub-actions[bot] <github-actions@users.noreply.github.com>
Tue, 27 Jun 2023 10:02:33 +0000 (12:02 +0200)
committerPiotr Czaja/Tizen Services & IoT (PLT) /SRPOL/Engineer/Samsung Electronics <p.czaja@samsung.com>
Mon, 3 Jul 2023 11:08:05 +0000 (13:08 +0200)
.github/workflows/synchronize_repos.yaml [new file with mode: 0644]

diff --git a/.github/workflows/synchronize_repos.yaml b/.github/workflows/synchronize_repos.yaml
new file mode 100644 (file)
index 0000000..c4e7acb
--- /dev/null
@@ -0,0 +1,37 @@
+name: Synchronize repositories
+on:
+  workflow_dispatch:
+jobs:
+  update_package_version:
+    runs-on: [ code-default ]
+    steps:
+      - name: Get code
+        uses: actions/checkout@v3
+        with:
+          fetch-depth: 0
+      - name: Checkout to tizen_next
+        run: git checkout remotes/origin/tizen_next -b local_tizen_next
+      - name: Install SSH key
+        uses: code-actions/shimataro-ssh-key-action@v2
+        with:
+          key: ${{ secrets.SSH_PRIVATE_KEY }}
+          name: id_rsa
+          known_hosts: ${{ secrets.KNOWN_HOSTS }}
+      - name: Get gerrit remote
+        run: |
+          git remote add gerrit ssh://${{ secrets.GERRIT_USERNAME }}@review.tizen.org:29418/profile/iot/apps/dotnet/settings
+          git fetch gerrit
+          git checkout remotes/gerrit/tizen -b gerrit_tizen
+      - name: Synchronize gerrit to github
+        run: |
+          if git merge-base --is-ancestor gerrit_tizen local_tizen_next; then 
+            NUMBER_OF_COMMITS=$(git rev-list --count gerrit_tizen..local_tizen_next)
+            echo Repository can be synchronized. Number of commits: $NUMBER_OF_COMMITS
+            git merge local_tizen_next
+          else
+            echo Repository can not be synchronized.
+            exit 1
+          fi
+      - name: Push changes
+        run: |
+          git push gerrit HEAD:tizen