diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 7b376cd..1f72f50 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -12,35 +12,53 @@ jobs: strategy: matrix: version: ['8.0', '8.1', '8.2'] + type: ['-swoole', '-nginx-swoole-prod'] steps: - name: Checkout code - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v4.1.1 - - name: Build - run: | - docker build --pull -t kooldev/php:${{ matrix.version }}-swoole ${{ matrix.version }}-swoole - docker build --pull -t kooldev/php:${{ matrix.version }}-nginx-swoole-prod ${{ matrix.version }}-nginx-swoole-prod + - name: Setup QEMU + uses: docker/setup-qemu-action@v3 - - name: Tests - run: | - docker run kooldev/php:${{ matrix.version }}-swoole php -r "extension_loaded('swoole') or die(1);" - docker run kooldev/php:${{ matrix.version }}-swoole node -v - docker run kooldev/php:${{ matrix.version }}-swoole yarn -v - docker run kooldev/php:${{ matrix.version }}-nginx-swoole-prod php -r "extension_loaded('swoole') or die(1);" + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - uses: docker/login-action@v2.1.0 + uses: docker/login-action@v3 if: github.ref == 'refs/heads/main' && github.repository == 'kool-dev/docker-php-swoole' with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Push to DockerHub - if: github.ref == 'refs/heads/main' && github.repository == 'kool-dev/docker-php-swoole' + - name: Build and export to Docker + uses: docker/build-push-action@v5 + with: + context: ${{ matrix.version }}${{ matrix.type }} + load: true + tags: kooldev/php:${{ matrix.version }}${{ matrix.type }} + + - name: Tests (dev) + if: matrix.type == '-swoole' run: | - docker push kooldev/php:${{ matrix.version }}-nginx-swoole - docker push kooldev/php:${{ matrix.version }}-nginx-swoole-prod + docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} php -r "extension_loaded('swoole') or die(1);" + docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} node -v + docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} yarn -v + + - name: Tests (prod) + if: matrix.type == '-nginx-swoole-prod' + run: | + docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} php -r "extension_loaded('swoole') or die(1);" + docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} nginx -v + + - name: Build and push + uses: docker/build-push-action@v5 + if: github.ref == 'refs/heads/main' && github.repository == 'kool-dev/docker-php-swoole' + with: + context: ${{ matrix.version }}${{ matrix.type }} + platforms: linux/amd64,linux/arm64 + push: true + tags: kooldev/php:${{ matrix.version }}${{ matrix.type }} trigger-build-oci8: name: Trigger OCI8 Build