|
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: "ubuntu-latest"}, {arch: "arm64", os: "ubuntu-latest"}] |
| 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: |
| 26 | + - name: Checkout |
| 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 |
21 | 33 | - name: Set up QEMU |
22 | | - uses: docker/setup-qemu-action@v1 |
| 34 | + uses: docker/setup-qemu-action@v2 |
23 | 35 | - name: Set up Docker Buildx |
24 | | - uses: docker/setup-buildx-action@v1 |
| 36 | + uses: docker/setup-buildx-action@v2 |
| 37 | + - name: Build |
| 38 | + run: | |
| 39 | + PHP_VERSION="${{ matrix.php_version }}" |
| 40 | + TAG_PREFIX="rc${GITHUB_SHA::7}-" \ |
| 41 | + docker buildx bake \ |
| 42 | + --set "*.platform=linux/${{ matrix.builder.arch }}" \ |
| 43 | + --set "*.output=type=docker" \ |
| 44 | + --load \ |
| 45 | + php${PHP_VERSION//.}-${{ matrix.variant }}-all |
| 46 | + - name: Display tags built |
| 47 | + run: | |
| 48 | + docker image ls --filter="reference=thecodingmachine/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}" |
| 49 | + - name: Test |
| 50 | + run: | |
| 51 | + TAG_PREFIX="rc${GITHUB_SHA::7}-" \ |
| 52 | + PHP_VERSION="${{ matrix.php_version }}" \ |
| 53 | + BRANCH="v4" \ |
| 54 | + VARIANT="${{ matrix.variant }}" \ |
| 55 | + PLATFORM="linux/${{ matrix.builder.arch }}" \ |
| 56 | + ./tests-suite/bash_unit -f tap ./tests-suite/*.sh |
| 57 | +
|
| 58 | + publish: |
| 59 | + # push ~ schedule |
| 60 | + # FIXME : re-enable after testing |
| 61 | +# if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} |
| 62 | + needs: |
| 63 | + - build |
| 64 | + runs-on: ubuntu-latest |
| 65 | + name: Publish multi-arch to dockerhub |
| 66 | + strategy: |
| 67 | + fail-fast: false |
| 68 | + matrix: |
| 69 | + php_version: ['8.1','8.0','7.4', '7.3','7.2'] |
| 70 | + variant: ['apache','cli','fpm'] |
| 71 | + steps: |
25 | 72 | - name: Checkout |
26 | | - uses: actions/checkout@v1 |
27 | | -# - name: Build locally |
28 | | -# run: | |
29 | | -# PHP_VERSION="${{ matrix.php_version }}" |
30 | | -# docker buildx bake --load \ |
31 | | -# --set "*.platform=linux/amd64" \ |
32 | | -# php${PHP_VERSION//.}-slim-${{ matrix.variant }} |
33 | | -# docker buildx bake --load \ |
34 | | -# --set "*.platform=linux/amd64" \ |
35 | | -# php${PHP_VERSION//.}-${{ matrix.variant }}-all |
36 | | -# PHP_VERSION_MINOR=`docker run --rm thecodingmachine/php:${PHP_VERSION}-v4-slim-cli php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` |
37 | | -# echo "PHP_VERSION_MINOR=${PHP_VERSION_MINOR}" >> $GITHUB_ENV |
38 | | -# echo "PHP Version : ${PHP_VERSION_MINOR}" >> $GITHUB_STEP_SUMMARY |
39 | | -# docker images --filter=reference=thecodingmachine/php >> $GITHUB_STEP_SUMMARY |
40 | | -# - name: Test ${{ matrix.variant }} |
41 | | -# run: | |
42 | | -# PHP_VERSION="${{ matrix.php_version }}" BRANCH=v4 VARIANT=${{ matrix.variant }} ./test-image.sh |
43 | | -# echo "${{ matrix.variant }} variant OK" >> $GITHUB_STEP_SUMMARY |
| 73 | + uses: actions/checkout@v3 |
| 74 | + - name: Set up QEMU |
| 75 | + uses: docker/setup-qemu-action@v2 |
| 76 | + - name: Set up Docker Buildx |
| 77 | + uses: docker/setup-buildx-action@v2 |
44 | 78 | - name: Login to DockerHub |
45 | | - # Merge ~ push. |
46 | | - if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} |
47 | 79 | uses: docker/login-action@v1 |
48 | 80 | with: |
49 | 81 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
50 | 82 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
51 | | - - name: Build and push to repository |
52 | | - # Merge ~ push. |
53 | | - if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} |
| 83 | + - name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }} as multiarch (amd64 and arm64) |
54 | 84 | run: | |
55 | 85 | PHP_VERSION="${{ matrix.php_version }}" |
| 86 | + |
| 87 | + TAG_PREFIX="rc${GITHUB_SHA::7}-" \ |
56 | 88 | docker buildx bake \ |
57 | 89 | --set "*.platform=linux/amd64,linux/arm64" \ |
58 | 90 | --set "*.output=type=registry" \ |
59 | 91 | php${PHP_VERSION//.}-slim-${{ matrix.variant }} |
60 | | - PHP_PATCH_MINOR=`docker run --rm thecodingmachine/php:${PHP_VERSION}-v4-slim-cli php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` \ |
| 92 | + PHP_PATCH_MINOR=`docker run --rm thecodingmachine/php:rc-${GITHUB_SHA::7}-${{ matrix.php_version }}-v4-slim-${{ matrix.variant }} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` |
| 93 | + PHP_VERSION="${{ matrix.php_version }}" |
| 94 | + |
| 95 | + TAG_PREFIX="rc${GITHUB_SHA::7}-" \ |
| 96 | + PHP_PATCH_MINOR="${PHP_VERSION_MINOR}" \ |
61 | 97 | docker buildx bake \ |
62 | 98 | --set "*.platform=linux/amd64,linux/arm64" \ |
63 | 99 | --set "*.output=type=registry" \ |
64 | 100 | php${PHP_VERSION//.}-${{ matrix.variant }}-all |
65 | | - docker images --filter=reference=thecodingmachine/php >> $GITHUB_STEP_SUMMARY |
| 101 | + - name: Display tags built |
| 102 | + run: | |
| 103 | + docker image ls --filter="reference=thecodingmachine/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}" |
0 commit comments