|
| 1 | +name: Direct build v5 of legacy php |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + test and publish: |
| 8 | + if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} |
| 9 | + needs: |
| 10 | + - test |
| 11 | + runs-on: ubuntu-latest |
| 12 | + name: Publish ${{ matrix.php_version }}-${{ matrix.variant }} multi-arch to dockerhub |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + php_version: ['8.1', '8.0', '7.4'] |
| 17 | + variant: ['apache','cli','fpm'] |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + - name: Set up QEMU |
| 22 | + uses: docker/setup-qemu-action@v3 |
| 23 | + - name: Set up Docker Buildx |
| 24 | + uses: docker/setup-buildx-action@v3 |
| 25 | + - name: Login to DockerHub |
| 26 | + uses: docker/login-action@v3 |
| 27 | + with: |
| 28 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 29 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 30 | + - name: Fetch minor version of php |
| 31 | + run: | |
| 32 | + # Build slim one |
| 33 | + PHP_VERSION="${{ matrix.php_version }}" |
| 34 | + TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ |
| 35 | + docker buildx bake \ |
| 36 | + --set "*.platform=linux/amd64" \ |
| 37 | + --set "*.output=type=docker" \ |
| 38 | + --load \ |
| 39 | + php${PHP_VERSION//.}-slim-${{ matrix.variant }} |
| 40 | + # Retrieve minor |
| 41 | + PHP_PATCH_MINOR=`docker run --rm thecodingmachine/php:rc${GITHUB_RUN_ID}-${{ matrix.php_version }}-v5-slim-${{ matrix.variant }} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` |
| 42 | + echo "PHP_PATCH_MINOR=${PHP_PATCH_MINOR}" >> $GITHUB_ENV |
| 43 | + - name: Display tags to build |
| 44 | + run: | |
| 45 | + PHP_VERSION="${{ matrix.php_version }}" |
| 46 | + PHP_PATCH_MINOR="${{ env.PHP_PATCH_MINOR }}" \ |
| 47 | + TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ |
| 48 | + IS_RELEASE="1" \ |
| 49 | + docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --print --progress plain | jq ".target[].tags | join(\" \")" -r > "/tmp/tags.log" |
| 50 | + cat "/tmp/tags.log" |
| 51 | + - name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }} |
| 52 | + run: | |
| 53 | + PHP_VERSION="${{ matrix.php_version }}" |
| 54 | + PHP_PATCH_MINOR="${{ env.PHP_PATCH_MINOR }}" \ |
| 55 | + TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ |
| 56 | + IS_RELEASE="1" \ |
| 57 | + docker buildx bake \ |
| 58 | + --set "*.platform=linux/amd64,linux/arm64" \ |
| 59 | + --set "*.output=type=registry" \ |
| 60 | + php${PHP_VERSION//.}-${{ matrix.variant }}-all |
| 61 | + - name: Push artifacts |
| 62 | + uses: actions/upload-artifact@v4 |
| 63 | + with: |
| 64 | + name: ${{ matrix.php_version }}-${{ matrix.variant }} |
| 65 | + path: /tmp/tags.log |
| 66 | + retention-days: 60 |
0 commit comments