Build, test and publish images #195
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 | |
| 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: | |
| fail-fast: false | |
| matrix: | |
| version: [ '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] | |
| 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 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'" | |
| run: docker push "${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" | |
| 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: | |
| fail-fast: false | |
| matrix: | |
| version: [ '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] | |
| 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 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'" | |
| run: docker push "${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" | |
| 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: | |
| fail-fast: false | |
| matrix: | |
| version: [ '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] | |
| 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 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'" | |
| run: docker push "${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" | |
| 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: | |
| fail-fast: false | |
| matrix: | |
| version: [ '8.0', '8.1', '8.2', '8.3', '8.4', '8.5' ] | |
| 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 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'" | |
| run: docker push "${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" |