check_submodules.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. git submodule update --init
  27. SUB_PATH="assets/protobuf";
  28. SUB_BRANCH="dev";
  29. SUB_COMMITS_MIN=40;
  30. cd "$SUB_PATH";
  31. SUBMODULE_HASH="$(git rev-parse HEAD)";
  32. BRANCHES=$(git branch -r --contains "$SUBMODULE_HASH");
  33. COMMITS_IN_BRANCH="$(git rev-list --count dev)";
  34. if [ $COMMITS_IN_BRANCH -lt $SUB_COMMITS_MIN ]; then
  35. echo "::set-output name=fails::error";
  36. echo "::error::Error: Too low commits in $SUB_BRANCH of submodule $SUB_PATH: $COMMITS_IN_BRANCH(expected $SUB_COMMITS_MIN+)";
  37. exit 1;
  38. fi
  39. if ! grep -q "/$SUB_BRANCH" <<< "$BRANCHES"; then
  40. echo "::set-output name=fails::error";
  41. echo "::error::Error: Submodule $SUB_PATH is not on branch $SUB_BRANCH";
  42. exit 1;
  43. fi