check_submodules.yml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. name: 'Check submodules branch'
  2. on:
  3. push:
  4. branches:
  5. - dev
  6. - "release*"
  7. tags:
  8. - '*'
  9. pull_request:
  10. jobs:
  11. check_protobuf:
  12. runs-on: [self-hosted, FlipperZeroShell]
  13. steps:
  14. - name: 'Decontaminate previous build leftovers'
  15. run: |
  16. if [ -d .git ]
  17. then
  18. git submodule status \
  19. || git checkout `git rev-list --max-parents=0 HEAD | tail -n 1`
  20. fi
  21. - name: 'Checkout code'
  22. uses: actions/checkout@v2
  23. with:
  24. fetch-depth: 0
  25. ref: ${{ github.event.pull_request.head.sha }}
  26. - name: 'Check protobuf branch'
  27. run: |
  28. SUB_PATH="assets/protobuf";
  29. SUB_BRANCH="dev";
  30. SUB_COMMITS_MIN=40;
  31. cd "$SUB_PATH";
  32. SUBMODULE_HASH="$(git rev-parse HEAD)";
  33. BRANCHES=$(git branch -r --contains "$SUBMODULE_HASH");
  34. COMMITS_IN_BRANCH="$(git rev-list --count dev)";
  35. if [ $COMMITS_IN_BRANCH -lt $SUB_COMMITS_MIN ]; then
  36. echo "::set-output name=fails::error";
  37. echo "::error::Error: Too low commits in $SUB_BRANCH of submodule $SUB_PATH: $COMMITS_IN_BRANCH(expected $SUB_COMMITS_MIN+)";
  38. exit 1;
  39. fi
  40. if ! grep -q "/$SUB_BRANCH" <<< "$BRANCHES"; then
  41. echo "::set-output name=fails::error";
  42. echo "::error::Error: Submodule $SUB_PATH is not on branch $SUB_BRANCH";
  43. exit 1;
  44. fi