Docker Image CI #832
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image CI | |
on: | |
workflow_dispatch: | |
push: | |
pull_request: | |
schedule: | |
- cron: '0 3 * * 0' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
continue-on-error: ${{ matrix.experimental }} | |
strategy: | |
matrix: | |
# Example | |
# | |
# php-base-image-version: "x.y-type" | |
# dockerfile-flavour: "debian" | |
# legacy-gd-lib: "" | |
# pecl-xdebug-suffix: "" | |
# pecl-mongodb-suffix: "" | |
# compose-file: "docker-compose.yml:..." | |
include: | |
- php-base-image-version: "8.1-fpm" | |
dockerfile-flavour: "debian" | |
compose-file: "docker-compose.yml,docker-compose.fpm-nginx.yml" | |
experimental: false | |
- php-base-image-version: "8.2-fpm" | |
dockerfile-flavour: "debian" | |
compose-file: "docker-compose.yml,docker-compose.fpm-nginx.yml" | |
experimental: false | |
- php-base-image-version: "8.3-fpm" | |
dockerfile-flavour: "debian" | |
compose-file: "docker-compose.yml,docker-compose.fpm-nginx.yml" | |
pecl-imagick-suffix: "/imagick@master" | |
experimental: false | |
- php-base-image-version: "8.1-apache" | |
dockerfile-flavour: "debian" | |
compose-file: "docker-compose.yml,docker-compose.apache.yml" | |
experimental: false | |
- php-base-image-version: "8.2-apache" | |
dockerfile-flavour: "debian" | |
compose-file: "docker-compose.yml,docker-compose.apache.yml" | |
experimental: false | |
- php-base-image-version: "8.3-apache" | |
dockerfile-flavour: "debian" | |
compose-file: "docker-compose.yml,docker-compose.apache.yml" | |
pecl-imagick-suffix: "/imagick@master" | |
experimental: false | |
fail-fast: false | |
env: | |
COMPOSE_FILE: ${{ matrix.compose-file }} | |
COMPOSE_PATH_SEPARATOR: "," | |
PHP_IMAGE_NAME: "yiisoftware/yii2-php" | |
PHP_BASE_IMAGE_VERSION: ${{ matrix.php-base-image-version }} | |
DOCKERFILE_FLAVOUR: ${{ matrix.dockerfile-flavour }} | |
X_LEGACY_GD_LIB: ${{ matrix.legacy-gd-lib }} | |
PECL_XDEBUG_INSTALL_SUFFIX: ${{ matrix.pecl-xdebug-suffix }} | |
PECL_MONGODB_INSTALL_SUFFIX: ${{ matrix.pecl-mongodb-suffix }} | |
PECL_IMAGICK_INSTALL_SUFFIX: ${{ matrix.pecl-imagick-suffix }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: 'amd64,arm64' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set version suffix (tags) | |
if: startsWith(github.ref, 'refs/tags/') | |
run: echo "PHP_IMAGE_VERSION_SUFFIX=-${GITHUB_REF:10}" >> $GITHUB_ENV | |
- name: Set version suffix (master/latest) | |
if: (github.ref == 'refs/heads/master' && (github.event_name != 'workflow_dispatch' && github.event_name != 'schedule')) | |
run: echo "PHP_IMAGE_VERSION_SUFFIX=-latest" >> $GITHUB_ENV | |
- name: Install | |
env: | |
TEST_YII_VERSION: "d43341a73ab9ab711c42b74c117e076275d9b8c0" | |
run: | | |
git clone https://github.com/yiisoft/yii2 _host-volumes/yii2 | |
pushd _host-volumes/yii2 && git checkout ${TEST_YII_VERSION} && popd | |
cp .env-dist .env | |
- name: Print Info | |
run: | | |
pwd | |
docker version | |
docker info | |
docker compose version | |
- name: Build Image | |
uses: docker/bake-action@v2 | |
with: | |
files: ${{ matrix.compose-file }} | |
load: true | |
set: | | |
*.platform=linux/amd64 | |
*.args.X_LEGACY_GD_LIB=${{ matrix.legacy-gd-lib }} | |
- name: Test | |
run: | | |
docker compose run --rm php-min php -v | grep "Xdebug" && exit 1 | |
docker compose run --rm php-min php /tests/requirements.php | |
docker compose run --rm php-dev php /tests/requirements.php | |
docker compose run --rm -w /yii2 php-dev composer update --prefer-dist | |
docker compose run --rm -w /yii2 php-dev php -d error_reporting="E_ALL ^ E_DEPRECATED" vendor/bin/phpunit tests/framework/ --exclude db | |
docker compose run --rm -e PHP_ENABLE_XDEBUG=1 php-dev php -v | grep "Xdebug" || exit 1 | |
docker images | |
- name: Login to Docker | |
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_PASS }} | |
- name: Build and push docker image (amd64 master/latest) | |
if: (github.ref == 'refs/heads/master' && (github.event_name != 'workflow_dispatch' && github.event_name != 'schedule')) | |
uses: docker/bake-action@v2 | |
with: | |
files: ${{ matrix.compose-file }} | |
push: true | |
set: | | |
*.platform=linux/amd64 | |
- name: Build and push docker image (amd64,arm64) | |
if: | | |
startsWith(github.ref, 'refs/tags/') || | |
(github.ref == 'refs/heads/master' && (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule')) | |
uses: docker/bake-action@v2 | |
with: | |
files: ${{ matrix.compose-file }} | |
push: true | |
set: | | |
*.platform=linux/amd64,linux/arm64 |