ci(fix): skip flow when there are no changes

```
Error when evaluating 'strategy' for job 'run_emqx_app_tests'. emqx/emqx/.github/workflows/run_emqx_app_tests.yaml@689347f60e5e2e5fc612aa0282c74c0eb26e8281 (Line: 65, Col: 9): Matrix must define at least one vector
```
This commit is contained in:
Thales Macedo Garitezi 2024-03-28 10:06:55 -03:00
parent 99ea63b25a
commit cb3be25ff4
1 changed files with 7 additions and 2 deletions

View File

@ -35,6 +35,7 @@ jobs:
shell: bash
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
skip: ${{ steps.matrix.outputs.skip }}
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
@ -49,12 +50,16 @@ jobs:
changed_files="$(git diff --name-only ${BEFORE_REF} ${AFTER_REF} apps/emqx)"
if [ "$changed_files" = '' ]; then
echo "nothing changed in apps/emqx, ignored."
echo "matrix=[]" | tee -a $GITHUB_OUTPUT
echo 'matrix=[]' | tee -a $GITHUB_OUTPUT
echo 'skip=true' | tee -a $GITHUB_OUTPUT
exit 0
else
echo 'skip=false' | tee -a $GITHUB_OUTPUT
echo 'matrix=[{"type": "eunit_proper_and_static"},{"type": "1_3"},{"type": "2_3"},{"type": "3_3"}]' | tee -a $GITHUB_OUTPUT
fi
echo 'matrix=[{"type": "eunit_proper_and_static"},{"type": "1_3"},{"type": "2_3"},{"type": "3_3"}]' | tee -a $GITHUB_OUTPUT
run_emqx_app_tests:
if: needs.prepare_matrix.outputs.skip != 'true'
needs:
- prepare_matrix
runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}