From e6079c9ab76b9da202c9a0d927702696b43acf01 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Thu, 13 Jun 2024 22:11:48 +0200 Subject: [PATCH] ci: add matrix --- .github/workflows/build.yml | 49 ++++++++++++++++++++++++++++++++++++- matrix.mjs | 18 ++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 matrix.mjs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a392ff..9223c9b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Login into Github Docker Registery + - name: Login into Docker Registery run: echo "${{ secrets.QUAY_ROBOT_PASSWORD }}" | docker login quay.io -u friendsofshopware+devcontainer_gh_actions --password-stdin - name: Install and configure Namespace CLI @@ -48,3 +48,50 @@ jobs: PHP_VERSION=${{ matrix.version }} push: true provenance: false + + generate-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.generate-matrix.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Generate Matrix + id: generate-matrix + run: | + MATRIX=$(node matrix.mjs) + echo "matrix<> $GITHUB_OUTPUT + echo "$MATRIX" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + build-shopware: + runs-on: ubuntu-latest + needs: generate-matrix + strategy: + fail-fast: false + matrix: + include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login into Docker Registery + run: echo "${{ secrets.QUAY_ROBOT_PASSWORD }}" | docker login quay.io -u friendsofshopware+devcontainer_gh_actions --password-stdin + + - name: Install and configure Namespace CLI + uses: namespacelabs/nscloud-setup@v0 + + - name: Configure Namespace powered Buildx + uses: namespacelabs/nscloud-setup-buildx-action@v0 + + - uses: docker/build-push-action@v5 + with: + tags: quay.io/friendsofshopware/devcontainer:${{ matrix.swVersion }}-${{ matrix.phpVersion }} + platforms: linux/amd64,linux/arm64 + file: Dockerfile.php + build-args: | + PHP_VERSION=${{ matrix.phpVersion }} + SHOPWARE_VERSION=${{ matrix.swVersion }} + push: true + provenance: false diff --git a/matrix.mjs b/matrix.mjs new file mode 100644 index 0000000..ccc20d1 --- /dev/null +++ b/matrix.mjs @@ -0,0 +1,18 @@ +const swToPHP = await (await fetch('https://raw.githubusercontent.com/FriendsOfShopware/shopware-static-data/main/data/all-supported-php-versions-by-shopware-version.json')).json(); + +const matrix = []; + +for (const swVersion of Object.keys(swToPHP)) { + if (swVersion.indexOf('6.6') !== 0 || swVersion.indexOf('RC') !== -1) { + continue; + } + + for (const phpVersion of swToPHP[swVersion]) { + matrix.push({ + swVersion, + phpVersion, + }); + } +} + +console.log(JSON.stringify(matrix, null, 2));