diff --git a/.github/workflows/build-mysql-container.yaml b/.github/workflows/build-mysql-container.yaml index 48f3d1d85..f1be9faf9 100644 --- a/.github/workflows/build-mysql-container.yaml +++ b/.github/workflows/build-mysql-container.yaml @@ -15,13 +15,39 @@ on: - "!**.md" jobs: + filter: + runs-on: ubuntu-20.04 + outputs: + mysql-versions: ${{ steps.filter.outputs.mysql-versions }} + steps: + - uses: actions/checkout@v3 + - name: filter + id: filter + working-directory: containers + run: | + array=() + + for dir in $(find ./mysql -mindepth 1 -type d -printf '%f\n'); do + result=$(./tag_exists moco/mysql "mysql/$dir") + + if [ "$result" = ng ]; then + array+=( "$dir" ) + fi + + done + + json_output=$(printf '%s\n' "${array[@]}" | jq -R . | jq -s . | jq -c .) + + echo "GITHUB_OUTPUT: mysql-versions=$json_output" + echo "mysql-versions=$json_output" >> "$GITHUB_OUTPUT" + tests: - if: github.event_name == 'pull_request' + if: ${{ (github.event_name == 'pull_request') && (needs.filter.outputs.mysql-versions != '[]') }} + needs: filter runs-on: ${{ vars.IMAGE_BUILD_RUNNER || 'ubuntu-20.04' }} strategy: matrix: - mysql-version: [ "8.0.18", "8.0.25", "8.0.26", "8.0.27", "8.0.28", "8.0.30", "8.0.31", "8.0.32" ] - k8s-version: [ "1.27.1" ] + mysql-version: ${{ fromJson(needs.filter.outputs.mysql-versions) }} steps: - uses: actions/checkout@v3 - uses: docker/setup-buildx-action@v2 @@ -58,16 +84,17 @@ jobs: - uses: ./.github/workflows/e2e.yaml with: - k8s-version: ${{ matrix.k8s-version }} + k8s-version: "1.27.1" mysql-version: ${{ matrix.mysql-version }} use-local-mysql-image: true build: - if: github.ref == 'refs/heads/main' + if: ${{ (github.ref == 'refs/heads/main') && (needs.filter.outputs.mysql-versions != '[]') }} + needs: filter runs-on: ${{ vars.IMAGE_BUILD_RUNNER || 'ubuntu-20.04' }} strategy: matrix: - mysql-version: [ "8.0.18", "8.0.25", "8.0.26", "8.0.27", "8.0.28", "8.0.30", "8.0.31", "8.0.32" ] + mysql-version: ${{ fromJson(needs.filter.outputs.mysql-versions) }} steps: - uses: actions/checkout@v3 - uses: docker/setup-qemu-action@v2