From c263337618153e93632ea2afe047d9a8f5385ede Mon Sep 17 00:00:00 2001 From: dhruvjoshi Date: Wed, 1 May 2024 00:41:05 +0530 Subject: [PATCH] INFRA-3209 | Dhruv | add github action for kutegen commit check --- .github/workflows/kutegen_submodule_check.yml | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/kutegen_submodule_check.yml diff --git a/.github/workflows/kutegen_submodule_check.yml b/.github/workflows/kutegen_submodule_check.yml new file mode 100644 index 00000000..223d64a0 --- /dev/null +++ b/.github/workflows/kutegen_submodule_check.yml @@ -0,0 +1,41 @@ +name: Kutegen submodule check + +on: + pull_request: + branches: + - master + - main +permissions: + contents: read + pull-requests: read + +jobs: + submodule-check: + runs-on: "docker" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + token: ${{ secrets.github_token }} + fetch-depth: 0 + fetch-tags: true + - name: Submodule update + run: git submodule update --init --recursive --depth 0 + - name: Check submodule + run: | + cd kutegen + git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" + git fetch origin main + BEHIND=$(git rev-list main ^HEAD --count) + AHEAD=$(git rev-list HEAD ^main --count) + if [ $AHEAD -gt 2 ]; then + echo "Submodule is more than 2 commits ahead of main branch." + exit 1 + elif [ $BEHIND -gt 2 ]; then + echo "Submodule is more than 2 commits behind main branch." + exit 1 + else + echo "Submodule is within 2 commits of main branch." + fi