From e22657f9532076255e202f30c191b91b1efe879f Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Tue, 30 Jan 2024 08:46:09 +0100
Subject: [PATCH] Run check after building images
---
.github/workflows/build.yml | 53 +++++++++++++++++++++++++++++++------
.github/workflows/pr.yml | 49 ----------------------------------
matrix.php | 18 +++++++++++++
3 files changed, 63 insertions(+), 57 deletions(-)
delete mode 100644 .github/workflows/pr.yml
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 35d4b81..cb33f32 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -146,14 +146,7 @@ jobs:
if: github.ref == 'refs/heads/main'
with:
tags: |
- ghcr.io/shopware/docker-base:${{ matrix.php }}-caddy
- ghcr.io/shopware/docker-base:${{ matrix.php }}
- ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}-caddy
- ghcr.io/shopware/docker-base:${{ matrix.phpPatch }}
- shopware/docker-base:${{ matrix.php }}-caddy
- shopware/docker-base:${{ matrix.php }}
- shopware/docker-base:${{ matrix.phpPatch }}-caddy
- shopware/docker-base:${{ matrix.phpPatch }}
+ ${{ matrix.caddy-tags }}
context: caddy
cache-from: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.php }}-caddy
cache-to: type=registry,ref=ghcr.io/shopware/docker-cache:${{ matrix.php }}-caddy,mode=max
@@ -165,3 +158,47 @@ jobs:
push: false
provenance: false
+ check:
+ name: Test Image
+ runs-on: ubuntu-latest
+ needs: [caddy]
+ steps:
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Checkout example repo
+ uses: actions/checkout@v4
+ with:
+ path: example-repo
+ repository: shopwareLabs/example-docker-repository
+
+ - name: Build
+ id: build
+ uses: docker/build-push-action@v5
+ with:
+ push: false
+ load: true
+ build-arg: |
+ BASE_IMAGE=ghcr.io/shopware/docker-base:${{ github.run_id }}-8.3-caddy
+ context: .
+ file: 8.3/Dockerfile
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Run image
+ env:
+ DOCKER_BUILDKIT: 0
+ working-directory: example-repo
+ run: docker compose up -d --wait
+
+ - name: Check if shopware is running
+ run: curl --fail localhost:8000/admin
+
+ # output logs if failed
+ - name: Output logs
+ working-directory: example-repo
+ run: docker compose logs
+ if: ${{ failure() }}
\ No newline at end of file
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
deleted file mode 100644
index 2d59b69..0000000
--- a/.github/workflows/pr.yml
+++ /dev/null
@@ -1,49 +0,0 @@
-name: Smoke test Image
-on:
- pull_request:
-
-jobs:
- check:
- name: Test Image
- runs-on: ubuntu-latest
- steps:
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Checkout example repo
- uses: actions/checkout@v4
- with:
- path: example-repo
- repository: shopwareLabs/example-docker-repository
-
- - name: Build
- id: build
- uses: docker/build-push-action@v5
- with:
- push: false
- load: true
- tags: |
- shopware/docker-base:8.3
- docker.io/shopware/docker-base:8.3
- context: .
- file: 8.3/Dockerfile
- cache-from: type=gha
- cache-to: type=gha,mode=max
-
- - name: Run image
- env:
- DOCKER_BUILDKIT: 0
- working-directory: example-repo
- run: docker compose up -d --wait
-
- - name: Check if shopware is running
- run: curl --fail localhost:8000/admin
-
- # output logs if failed
- - name: Output logs
- working-directory: example-repo
- run: docker compose logs
- if: ${{ failure() }}
diff --git a/matrix.php b/matrix.php
index 6802f1e..9d13067 100644
--- a/matrix.php
+++ b/matrix.php
@@ -41,15 +41,33 @@
$imagePrefix = $_SERVER['GITHUB_RUN_ID'] ? ($_SERVER['GITHUB_RUN_ID'] . '-') : '';
+ $caddyImages = [
+ 'ghcr.io/shopware/docker-base:' . $imagePrefix . $supportedVersion,
+ 'ghcr.io/shopware/docker-base:' . $imagePrefix . $supportedVersion . '-caddy',
+ 'ghcr.io/shopware/docker-base:' . $imagePrefix . $patchVersion['version'],
+ 'ghcr.io/shopware/docker-base:' . $imagePrefix . $$patchVersion['version'] . '-caddy',
+ ];
+
+ if (!$imagePrefix) {
+ $caddyImages = array_merge($caddyImages, [
+ 'shopware/docker-base:' . $imagePrefix . $supportedVersion,
+ 'shopware/docker-base:' . $imagePrefix . $supportedVersion . '-caddy',
+ 'shopware/docker-base:' . $imagePrefix . $patchVersion['version'],
+ 'shopware/docker-base:' . $imagePrefix . $patchVersion['version'] . '-caddy',
+ ]);
+ }
+
$data[] = [
'php' => $supportedVersion,
'phpPatch' => $patchVersion['version'],
'phpPatchDigest' => $phpDigest,
'supervisordDigest' => $supervisord,
+ 'base-image' => 'ghcr.io/shopware/docker-base:' . $imagePrefix . $supportedVersion,
'fpm-image' => 'ghcr.io/shopware/docker-base:' . $imagePrefix . $supportedVersion . '-fpm',
'fpm-patch-image' => 'ghcr.io/shopware/docker-base:' . $imagePrefix . $patchVersion['version'] . '-fpm',
'fpm-hub-image' => 'shopware/docker-base:' . $imagePrefix . $supportedVersion . '-fpm',
'fpm-patch-hub-image' => 'shopware/docker-base:' . $imagePrefix . $patchVersion['version'] . '-fpm',
+ 'caddy-tags' => implode("\n", $caddyImages),
];
}