|
11 | 11 | - cron: '42 3 * * 0' |
12 | 12 |
|
13 | 13 | jobs: |
14 | | - build_test_maybe_release: |
| 14 | + build: |
15 | 15 | strategy: |
| 16 | + fail-fast: false |
16 | 17 | matrix: |
17 | 18 | php_version: ['8.1','8.0','7.4', '7.3','7.2'] |
18 | 19 | variant: ['apache','cli','fpm'] |
19 | | - runs-on: ubuntu-latest |
| 20 | + builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "macos-latest"}] |
| 21 | + # builder: [ {arch: "amd64", os: "self-hosted"}, {arch: "arm64", os: "self-hosted"}] |
| 22 | + runs-on: ${{ matrix.builder.os }} |
| 23 | +# runs-on: self-hosted |
| 24 | + name: Build & test ${{ matrix.php_version }}-${{ matrix.variant }} (${{ matrix.builder.arch }}) |
20 | 25 | steps: |
21 | 26 | - name: Checkout |
22 | 27 | uses: actions/checkout@v3 |
| 28 | + - name: Set up Docker |
| 29 | + # /!\ this action is marked as experimental |
| 30 | + # It's required only for macos |
| 31 | + if: ${{ matrix.builder.os == 'macos-latest' }} |
| 32 | + uses: docker-practice/actions-setup-docker@master |
23 | 33 | - name: Set up QEMU |
24 | 34 | uses: docker/setup-qemu-action@v2 |
25 | 35 | - name: Set up Docker Buildx |
26 | 36 | uses: docker/setup-buildx-action@v2 |
27 | | - - name: Build locally (amd64) |
| 37 | + - name: Expose GitHub Runtime for docker cache |
| 38 | + uses: crazy-max/ghaction-github-runtime@v2 |
| 39 | + - name: Build |
28 | 40 | run: | |
29 | 41 | PHP_VERSION="${{ matrix.php_version }}" |
30 | | - docker buildx bake --load \ |
31 | | - --set "*.platform=linux/amd64" \ |
| 42 | + TAG_PREFIX="rc-${{ env.GITHUB_SHA_SHORT }}-" \ |
| 43 | + docker buildx bake \ |
| 44 | + --set "*.platform=linux/${{ matrix.builder.arch }}" \ |
| 45 | + --set "*.output=type=docker" \ |
32 | 46 | php${PHP_VERSION//.}-${{ matrix.variant }}-all |
33 | | - # Fetch minor version |
34 | | - PHP_VERSION_MINOR=`docker run --rm thecodingmachine/php:${PHP_VERSION}-v4-slim-${{ matrix.variant }} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` |
35 | | - echo "PHP_VERSION_MINOR=${PHP_VERSION_MINOR}" >> $GITHUB_ENV |
36 | | - # Summary |
37 | | - echo "PHP Version : ${PHP_VERSION_MINOR}" >> $GITHUB_STEP_SUMMARY |
38 | | - docker images --filter=reference=thecodingmachine/php >> $GITHUB_STEP_SUMMARY |
39 | | - docker images --filter=reference=thecodingmachine/php |
40 | | - - name: Test variant '${{ matrix.variant }}' (amd64) |
41 | | - run: | |
42 | | - PHP_VERSION="${{ matrix.php_version }}" BRANCH=v4 VARIANT=${{ matrix.variant }} ./tests-suite/bash_unit -f tap ./tests-suite/*.sh |
| 47 | + - name: Test |
| 48 | + run: | |
| 49 | + TAG_PREFIX="rc-${{ env.GITHUB_SHA_SHORT }}-" \ |
| 50 | + PHP_VERSION="${{ matrix.php_version }}" BRANCH=v4 VARIANT=${{ matrix.variant }} PLATFORM=linux/${{ matrix.builder.arch }} ./tests-suite/bash_unit -f tap ./tests-suite/*.sh |
| 51 | +
|
| 52 | + publish: |
| 53 | + # push ~ schedule |
| 54 | + if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} |
| 55 | + needs: |
| 56 | + - build |
| 57 | + runs-on: ubuntu-latest |
| 58 | + name: Publish multi-arch to dockerhub |
| 59 | + strategy: |
| 60 | + fail-fast: false |
| 61 | + matrix: |
| 62 | + php_version: ['8.1'] #,'8.0','7.4', '7.3','7.2'] |
| 63 | + variant: ['apache'] #,'cli','fpm'] |
| 64 | + steps: |
| 65 | + - name: Checkout |
| 66 | + uses: actions/checkout@v3 |
| 67 | + - name: Set up QEMU |
| 68 | + uses: docker/setup-qemu-action@v2 |
| 69 | + - name: Set up Docker Buildx |
| 70 | + uses: docker/setup-buildx-action@v2 |
| 71 | + - name: Expose GitHub Runtime for docker cache |
| 72 | + uses: crazy-max/ghaction-github-runtime@v2 |
43 | 73 | - name: Login to DockerHub |
44 | | - # Merge ~ push. |
45 | | - if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} |
46 | 74 | uses: docker/login-action@v1 |
47 | 75 | with: |
48 | 76 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
49 | 77 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
50 | | - - name: Build and push to repository (both amd64 and arm64) |
51 | | - # Merge ~ push. |
52 | | - if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} |
| 78 | + - name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }} as multiarch (amd64 and arm64) |
53 | 79 | run: | |
| 80 | + TAG_PREFIX="rc-${{ env.GITHUB_SHA_SHORT }}-" \ |
| 81 | + docker buildx bake \ |
| 82 | + --set "*.cache-from=type=gha" \ |
| 83 | + --set "*.platform=linux/amd64,linux/arm64" \ |
| 84 | + --set "*.output=type=registry" \ |
| 85 | + php${PHP_VERSION//.}-slim-${{ matrix.variant }} |
| 86 | + PHP_PATCH_MINOR=`docker run --rm thecodingmachine/php:rc-${{ env.GITHUB_SHA_SHORT }}-${{ matrix.php_version }}-v4-slim-${{ matrix.variant }} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` |
54 | 87 | PHP_VERSION="${{ matrix.php_version }}" |
| 88 | + TAG_PREFIX="rc-${{ env.GITHUB_SHA_SHORT }}-" \ |
55 | 89 | PHP_PATCH_MINOR="${{ env.PHP_VERSION_MINOR }}" \ |
56 | 90 | docker buildx bake \ |
| 91 | + --set "*.cache-from=gha" \ |
57 | 92 | --set "*.platform=linux/amd64,linux/arm64" \ |
58 | 93 | --set "*.output=type=registry" \ |
59 | 94 | php${PHP_VERSION//.}-${{ matrix.variant }}-all |
0 commit comments