INFRA-3209 | Dhruv | add github action for kutegen commit check
This commit is contained in:
41
.github/workflows/kutegen_submodule_check.yml
vendored
Normal file
41
.github/workflows/kutegen_submodule_check.yml
vendored
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user