name: Continuous Integration Pull Request

on:
    pull_request:

jobs:
    test:
        strategy:
            fail-fast: false
            matrix: ${{ fromJson(vars.BUNDLE_MATRIX) }}
        uses: globaldigitalagency/github-workflows-templates/.github/workflows/bundle-test.yaml@v8
        with:
            php-version: ${{ matrix.php }}
            symfony-version: ${{ matrix.symfony }}
            dependencies: ${{ matrix.dependencies }}
        secrets: inherit

    validate-bundle:
        needs: update-satis
        strategy:
            fail-fast: false
            matrix: ${{ fromJson(vars.BUNDLE_MATRIX) }}
        uses: globaldigitalagency/github-workflows-templates/.github/workflows/bundle-validate.yaml@v8
        with:
            project: gda/autoadmin
            branch: ${{ github.head_ref }}
            php-version: ${{ matrix.php }}
            symfony-version: ${{ matrix.symfony }}
            dependencies: ${{ matrix.dependencies }}
        secrets: inherit

    analysis:
        uses: globaldigitalagency/github-workflows-templates/.github/workflows/sonarqube.yaml@v8
        needs: test
        secrets: inherit
        with:
            reference-branch: ${{ github.base_ref }}
            branch: ${{ github.head_ref }}

    build-status:
        runs-on: ubuntu-22.04
        needs: [ test, validate-bundle ]
        if: always()
        steps:
            -   run: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'skipped') }}

    update-satis:
        uses: globaldigitalagency/github-workflows-templates/.github/workflows/bundle-update-satis.yaml@v8
        secrets: inherit
