|
| 1 | +name: "PHP Docker NE images delivery" |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # once per week |
| 6 | + - cron: "0 4 1,14 * *" |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - "v*.*.*" |
| 10 | + |
| 11 | +jobs: |
| 12 | + Deploy: |
| 13 | + name: "Image deployment" |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + base-image: ['debian', 'alpine'] |
| 17 | + php-version: ['8.3', '8.0', '8.1', '8.2'] |
| 18 | + target: ['cli', 'fpm'] |
| 19 | + exclude: |
| 20 | + - base-image: alpine |
| 21 | + php-version: '8.3' |
| 22 | + - base-image: alpine |
| 23 | + php-version: '8.0' |
| 24 | + fail-fast: false |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Checkout code |
| 28 | + uses: actions/checkout@v4 |
| 29 | + - name: Build testing Docker Image |
| 30 | + uses: docker/build-push-action@v5 |
| 31 | + with: |
| 32 | + push: false |
| 33 | + file: ./${{ matrix.base-image }}/Dockerfile |
| 34 | + context: ./${{ matrix.base-image }}/ |
| 35 | + target: ${{ matrix.target }} |
| 36 | + tags: testing |
| 37 | + build-args: PHP_VERSION=${{ matrix.php-version }} |
| 38 | + - name: Dump installed PHP version |
| 39 | + run: echo "PHP_REAL_VERSION=$(docker run testing -v | grep -Eo -m 1 '[0-9]+\.[0-9]+\.[0-9]+')" >> $GITHUB_ENV |
| 40 | + - name: Check PHP version |
| 41 | + run: echo "${{ env.PHP_REAL_VERSION }}" | grep "${{ matrix.php-version }}" |
| 42 | + - name: Perform image tests |
| 43 | + run: IMAGE_TAG=testing ./.github/workflows/test-image.sh |
| 44 | + - name: "Check FPM" |
| 45 | + if: ${{ 'fpm' == matrix.target }} |
| 46 | + run: | |
| 47 | + docker run testing find /usr/bin/php-fpm |
| 48 | + docker run testing /usr/bin/php-fpm --daemonize |
| 49 | + - name: "Check CLI" |
| 50 | + if: ${{ 'cli' == matrix.target }} |
| 51 | + run: docker run testing | grep "Interactive" |
| 52 | + - name: Set up QEMU (multiplatform) |
| 53 | + uses: docker/setup-qemu-action@v3 |
| 54 | + - name: Set up Docker Buildx (multiplatform) |
| 55 | + uses: docker/setup-buildx-action@v3 |
| 56 | + - name: Login to Docker Hub |
| 57 | + uses: docker/login-action@v3 |
| 58 | + with: |
| 59 | + username: ${{ secrets.NE_DOCKERHUB_USERNAME }} |
| 60 | + password: ${{ secrets.NE_DOCKERHUB_TOKEN }} |
| 61 | + - name: Prepare image metadata |
| 62 | + id: meta |
| 63 | + uses: docker/metadata-action@v4 |
| 64 | + with: |
| 65 | + images: ${{ secrets.NE_DOCKERHUB_USERNAME }}/php |
| 66 | + # sample tag output: 8.2-cli, 8.2.11, latest, cli, 8.2.11-cli, 8.2.11-cli-20230712, 8.2.11 |
| 67 | + tags: | |
| 68 | + type=raw,value=${{ matrix.php-version }}-${{ matrix.target }},enable=${{ 'debian' == matrix.base-image }} |
| 69 | + type=raw,value=${{ matrix.php-version }},enable=${{ 'cli' == matrix.target && 'debian' == matrix.base-image }} |
| 70 | + type=raw,value=latest,enable=${{ '8.2' == matrix.php-version && 'cli' == matrix.target && 'debian' == matrix.base-image }} |
| 71 | + type=raw,value=${{ matrix.target }},enable=${{ '8.2' == matrix.php-version && 'debian' == matrix.base-image }} |
| 72 | + type=raw,value=${{ env.PHP_REAL_VERSION }}-${{ matrix.target }},enable=${{ 'debian' == matrix.base-image }} |
| 73 | + type=raw,value=${{ env.PHP_REAL_VERSION }}-${{ matrix.target }}-{{ date 'YYYYMMDD' }},enable=${{ 'debian' == matrix.base-image }} |
| 74 | + type=raw,value=${{ env.PHP_REAL_VERSION }},enable=${{ 'cli' == matrix.target && 'debian' == matrix.base-image }} |
| 75 | +
|
| 76 | + type=raw,value=${{ matrix.php-version }}-${{ matrix.target }}-${{ matrix.base-image }} |
| 77 | + type=raw,value=${{ matrix.php-version }}-${{ matrix.base-image }},enable=${{ 'cli' == matrix.target }} |
| 78 | + type=raw,value=${{ matrix.target }}-${{ matrix.base-image }},enable=${{ '8.2' == matrix.php-version }} |
| 79 | + type=raw,value=${{ env.PHP_REAL_VERSION }}-${{ matrix.target }}-${{ matrix.base-image }} |
| 80 | + type=raw,value=${{ env.PHP_REAL_VERSION }}-${{ matrix.target }}-{{date 'YYYYMMDD'}}-${{ matrix.base-image }} |
| 81 | + type=raw,value=${{ env.PHP_REAL_VERSION }}-${{ matrix.base-image }},enable=${{ 'cli' == matrix.target }} |
| 82 | + - name: Build & push to Docker Hub |
| 83 | + uses: docker/build-push-action@v5 |
| 84 | + with: |
| 85 | + push: true |
| 86 | + file: ./${{ matrix.base-image }}/Dockerfile |
| 87 | + context: ./${{ matrix.base-image }}/ |
| 88 | + platforms: linux/amd64,linux/arm64 |
| 89 | + target: ${{ matrix.target }} |
| 90 | + tags: ${{ steps.meta.outputs.tags }}, |
| 91 | + labels: ${{ steps.meta.outputs.labels }}, |
| 92 | + build-args: PHP_VERSION=${{ matrix.php-version }} |
0 commit comments