diff --git a/.github/workflows/molecule.yaml b/.github/workflows/molecule.yaml index 518d6218c..40e8cf59f 100644 --- a/.github/workflows/molecule.yaml +++ b/.github/workflows/molecule.yaml @@ -55,13 +55,25 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.9' + - name: Check whether the role is modified + id: check_role + run: | + if [[ $(git diff --name-only roles | grep "${{ matrix.tested_role }}/") ]]; then + echo "modified=true" >> $GITHUB_OUTPUT + else + echo "modified=false" >> $GITHUB_OUTPUT + fi - name: Install ansible + if: steps.check_role.outputs.modified == 'true' run: pip install ansible - name: Install collections + if: steps.check_role.outputs.modified == 'true' run: ansible-galaxy collection install --force -r requirements.yml - name: Install molecule deps + if: steps.check_role.outputs.modified == 'true' run: pip install -r molecule-requirements.txt - name: Run molecule test + if: steps.check_role.outputs.modified == 'true' run: | cd $GITHUB_WORKSPACE/roles/${{ matrix.tested_role }} molecule test --all