Build, test and publish images #185
This file contains hidden or 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: Build, test and publish images | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: [ opened, synchronize ] | |
| schedule: | |
| - cron: 0 0 * * 0 | |
| env: | |
| PLATFORMS: linux/amd64,linux/arm64 | |
| jobs: | |
| base-images: | |
| name: Build, test and publish base images | |
| runs-on: ubuntu-latest | |
| if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')" | |
| strategy: | |
| matrix: | |
| version: [ '8.0', '8.1', '8.2', '8.3', '8.4' ] | |
| flavor: [ '', '-fpm' ] | |
| distro: [ '', '-alpine' ] | |
| env: | |
| IMAGE_NAME: columbusinteractive/php | |
| IMAGE_TAG: ${{ matrix.version }}${{ matrix.flavor }}${{ matrix.distro }} | |
| BASE_IMAGE_TAG: ${{ matrix.version }}${{ matrix.flavor }}${{ matrix.distro }} | |
| BASE_DIR: . | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Dockerfile | |
| run: | | |
| if ! test -r Dockerfile && test -r Dockerfile.m4; then | |
| m4 Dockerfile.m4 > Dockerfile | |
| fi | |
| working-directory: ${{ env.BASE_DIR }} | |
| - name: Build image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ env.BASE_DIR }} | |
| build-args: BASE_IMAGE_TAG=${{ env.BASE_IMAGE_TAG }} | |
| pull: true | |
| cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| load: true | |
| - name: Test image | |
| run: make -C ${{ env.BASE_DIR }} "IMAGE_NAME=${{ env.IMAGE_NAME }}" "IMAGE_TAG=${{ env.IMAGE_TAG }}" test | |
| - name: Login to DockerHub | |
| if: "github.event_name != 'pull_request'" | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Push image to registry | |
| if: "github.event_name != 'pull_request'" | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: ${{ env.PLATFORMS }} | |
| context: ${{ env.BASE_DIR }} | |
| build-args: BASE_IMAGE_TAG=${{ env.BASE_IMAGE_TAG }} | |
| pull: true | |
| cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| push: true | |
| dev-images: | |
| name: Build, test and publish dev images | |
| runs-on: ubuntu-latest | |
| if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')" | |
| needs: base-images | |
| strategy: | |
| matrix: | |
| version: [ '8.0', '8.1', '8.2', '8.3', '8.4' ] | |
| flavor: [ '', '-fpm' ] | |
| distro: [ '', '-alpine' ] | |
| env: | |
| IMAGE_NAME: columbusinteractive/php-dev | |
| IMAGE_TAG: ${{ matrix.version }}${{ matrix.flavor }}${{ matrix.distro }} | |
| BASE_IMAGE_TAG: ${{ matrix.version }}${{ matrix.flavor }}${{ matrix.distro }} | |
| BASE_DIR: ./dev | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Dockerfile | |
| run: | | |
| if ! test -r Dockerfile && test -r Dockerfile.m4; then | |
| m4 Dockerfile.m4 > Dockerfile | |
| fi | |
| working-directory: ${{ env.BASE_DIR }} | |
| - name: Build image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ env.BASE_DIR }} | |
| build-args: BASE_IMAGE_TAG=${{ env.BASE_IMAGE_TAG }} | |
| pull: true | |
| cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| load: true | |
| - name: Test image | |
| run: make -C ${{ env.BASE_DIR }} "IMAGE_NAME=${{ env.IMAGE_NAME }}" "IMAGE_TAG=${{ env.IMAGE_TAG }}" test | |
| - name: Login to DockerHub | |
| if: "github.event_name != 'pull_request'" | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Push image to registry | |
| if: "github.event_name != 'pull_request'" | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: ${{ env.PLATFORMS }} | |
| context: ${{ env.BASE_DIR }} | |
| build-args: BASE_IMAGE_TAG=${{ env.BASE_IMAGE_TAG }} | |
| pull: true | |
| cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| push: true | |
| swoole-images: | |
| name: Build, test and publish swoole images | |
| runs-on: ubuntu-latest | |
| if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')" | |
| needs: base-images | |
| strategy: | |
| matrix: | |
| version: [ '8.0', '8.1', '8.2', '8.3', '8.4' ] | |
| distro: [ '', '-alpine' ] | |
| env: | |
| IMAGE_NAME: columbusinteractive/php-swoole | |
| IMAGE_TAG: ${{ matrix.version }}${{ matrix.distro }} | |
| BASE_IMAGE_TAG: ${{ matrix.version }}${{ matrix.distro }} | |
| BASE_DIR: ./swoole | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Dockerfile | |
| run: | | |
| if ! test -r Dockerfile && test -r Dockerfile.m4; then | |
| m4 Dockerfile.m4 > Dockerfile | |
| fi | |
| working-directory: ${{ env.BASE_DIR }} | |
| - name: Build image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ env.BASE_DIR }} | |
| build-args: BASE_IMAGE_TAG=${{ env.BASE_IMAGE_TAG }} | |
| pull: true | |
| cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| load: true | |
| - name: Test image | |
| run: make -C ${{ env.BASE_DIR }} "IMAGE_NAME=${{ env.IMAGE_NAME }}" "IMAGE_TAG=${{ env.IMAGE_TAG }}" test | |
| - name: Login to DockerHub | |
| if: "github.event_name != 'pull_request'" | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Push image to registry | |
| if: "github.event_name != 'pull_request'" | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: ${{ env.PLATFORMS }} | |
| context: ${{ env.BASE_DIR }} | |
| build-args: BASE_IMAGE_TAG=${{ env.BASE_IMAGE_TAG }} | |
| pull: true | |
| cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| push: true | |
| parallel-images: | |
| name: Build, test and publish parallel images | |
| runs-on: ubuntu-latest | |
| if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')" | |
| strategy: | |
| matrix: | |
| version: [ '8.0', '8.1', '8.2', '8.3', '8.4' ] | |
| distro: [ '', '-alpine' ] | |
| env: | |
| IMAGE_NAME: columbusinteractive/php-parallel | |
| IMAGE_TAG: ${{ matrix.version }}${{ matrix.distro }} | |
| BASE_IMAGE_TAG: ${{ matrix.version }}-zts${{ matrix.distro }} | |
| BASE_DIR: ./parallel | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Dockerfile | |
| run: | | |
| if ! test -r Dockerfile && test -r Dockerfile.m4; then | |
| m4 Dockerfile.m4 > Dockerfile | |
| fi | |
| working-directory: ${{ env.BASE_DIR }} | |
| - name: Build image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ env.BASE_DIR }} | |
| build-args: BASE_IMAGE_TAG=${{ env.BASE_IMAGE_TAG }} | |
| pull: true | |
| cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| load: true | |
| - name: Test image | |
| run: make -C ${{ env.BASE_DIR }} "IMAGE_NAME=${{ env.IMAGE_NAME }}" "IMAGE_TAG=${{ env.IMAGE_TAG }}" test | |
| - name: Login to DockerHub | |
| if: "github.event_name != 'pull_request'" | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Push image to registry | |
| if: "github.event_name != 'pull_request'" | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: ${{ env.PLATFORMS }} | |
| context: ${{ env.BASE_DIR }} | |
| build-args: BASE_IMAGE_TAG=${{ env.BASE_IMAGE_TAG }} | |
| pull: true | |
| cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | |
| push: true |