check_submodules.yml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 ]; then
  17. git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
  18. fi
  19. - name: 'Checkout code'
  20. uses: actions/checkout@v2
  21. with:
  22. fetch-depth: 0
  23. ref: ${{ github.event.pull_request.head.sha }}
  24. - name: 'Check protobuf branch'
  25. run: |
  26. SUB_PATH="assets/protobuf";
  27. SUB_BRANCH="dev";
  28. SUB_COMMITS_MIN=40;
  29. cd "$SUB_PATH";
  30. SUBMODULE_HASH="$(git rev-parse HEAD)";
  31. BRANCHES=$(git branch -r --contains "$SUBMODULE_HASH");
  32. COMMITS_IN_BRANCH="$(git rev-list --count dev)";
  33. if [ $COMMITS_IN_BRANCH -lt $SUB_COMMITS_MIN ]; then
  34. echo "::set-output name=fails::error";
  35. echo "::error::Error: Too low commits in $SUB_BRANCH of submodule $SUB_PATH: $COMMITS_IN_BRANCH(expected $SUB_COMMITS_MIN+)";
  36. exit 1;
  37. fi
  38. if ! grep -q "/$SUB_BRANCH" <<< "$BRANCHES"; then
  39. echo "::set-output name=fails::error";
  40. echo "::error::Error: Submodule $SUB_PATH is not on branch $SUB_BRANCH";
  41. exit 1;
  42. fi