|
7 | 7 | push:
|
8 | 8 | branches:
|
9 | 9 | - 'v4'
|
10 |
| -# schedule: |
11 |
| -# - cron: '42 3 * * 0' |
| 10 | + schedule: |
| 11 | + - cron: '42 3 * * 0' |
12 | 12 |
|
13 | 13 | jobs:
|
14 |
| - build_test_maybe_release: |
| 14 | + test: |
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 | + name: Test ${{ matrix.php_version }}-${{ matrix.variant }} ${{ matrix.builder.arch }} only |
20 | 24 | steps:
|
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v3 |
| 27 | + - name: Set up Docker |
| 28 | + # /!\ this action is marked as experimental |
| 29 | + # It's required only for macos |
| 30 | + if: ${{ matrix.builder.os == 'macos-latest' }} |
| 31 | + uses: docker-practice/actions-setup-docker@master |
21 | 32 | - name: Set up QEMU
|
22 |
| - uses: docker/setup-qemu-action@v1 |
| 33 | + uses: docker/setup-qemu-action@v2 |
23 | 34 | - name: Set up Docker Buildx
|
24 |
| - uses: docker/setup-buildx-action@v1 |
| 35 | + uses: docker/setup-buildx-action@v2 |
| 36 | + - name: Build |
| 37 | + run: | |
| 38 | + PHP_VERSION="${{ matrix.php_version }}" |
| 39 | + TAG_PREFIX="rc${GITHUB_SHA::7}-" \ |
| 40 | + docker buildx bake \ |
| 41 | + --set "*.platform=linux/${{ matrix.builder.arch }}" \ |
| 42 | + --set "*.output=type=docker" \ |
| 43 | + --load \ |
| 44 | + php${PHP_VERSION//.}-${{ matrix.variant }}-all |
| 45 | + - name: Display tags built |
| 46 | + run: | |
| 47 | + docker image ls --filter="reference=thecodingmachine/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}" |
| 48 | + - name: Test |
| 49 | + run: | |
| 50 | + TAG_PREFIX="rc${GITHUB_SHA::7}-" \ |
| 51 | + PHP_VERSION="${{ matrix.php_version }}" \ |
| 52 | + BRANCH="v4" \ |
| 53 | + VARIANT="${{ matrix.variant }}" \ |
| 54 | + PLATFORM="linux/${{ matrix.builder.arch }}" \ |
| 55 | + ./tests-suite/bash_unit -f tap ./tests-suite/*.sh |
| 56 | +
|
| 57 | + publish: |
| 58 | + # push ~ schedule |
| 59 | + if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} |
| 60 | + needs: |
| 61 | + - test |
| 62 | + runs-on: ubuntu-latest |
| 63 | + name: Publish ${{ matrix.php_version }}-${{ matrix.variant }} multi-arch to dockerhub |
| 64 | + strategy: |
| 65 | + fail-fast: false |
| 66 | + matrix: |
| 67 | + php_version: ['8.1','8.0','7.4', '7.3','7.2'] |
| 68 | + variant: ['apache','cli','fpm'] |
| 69 | + steps: |
25 | 70 | - 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 |
| 71 | + uses: actions/checkout@v3 |
| 72 | + - name: Set up QEMU |
| 73 | + uses: docker/setup-qemu-action@v2 |
| 74 | + - name: Set up Docker Buildx |
| 75 | + uses: docker/setup-buildx-action@v2 |
44 | 76 | - name: Login to DockerHub
|
45 |
| - # Merge ~ push. |
46 |
| - if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} |
47 | 77 | uses: docker/login-action@v1
|
48 | 78 | with:
|
49 | 79 | username: ${{ secrets.DOCKERHUB_USERNAME }}
|
50 | 80 | password: ${{ secrets.DOCKERHUB_TOKEN }}
|
51 |
| - - name: Build and push to repository |
52 |
| - # Merge ~ push. |
53 |
| - if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} |
| 81 | + - name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }} with tagged prefix |
54 | 82 | run: |
|
55 | 83 | PHP_VERSION="${{ matrix.php_version }}"
|
| 84 | + TAG_PREFIX="rc${GITHUB_SHA::7}-" \ |
56 | 85 | docker buildx bake \
|
57 | 86 | --set "*.platform=linux/amd64,linux/arm64" \
|
58 | 87 | --set "*.output=type=registry" \
|
59 |
| - 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` \ |
| 88 | + php${PHP_VERSION//.}-${{ matrix.variant }}-all |
| 89 | + - name: Fetch minor version of php |
| 90 | + run: | |
| 91 | + # Retrieve minor version |
| 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 | + echo "PHP_PATCH_MINOR=${PHP_PATCH_MINOR}" >> $GITHUB_ENV |
| 94 | + - name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }} with releases tags (major and minor) |
| 95 | + run: | |
| 96 | + PHP_VERSION="${{ matrix.php_version }}" |
| 97 | + PHP_PATCH_MINOR="${PHP_VERSION_MINOR}" \ |
61 | 98 | docker buildx bake \
|
62 | 99 | --set "*.platform=linux/amd64,linux/arm64" \
|
63 | 100 | --set "*.output=type=registry" \
|
| 101 | + --metadata-file "/tmp/digests-php${PHP_VERSION//.}-${{ matrix.variant }}.log" |
64 | 102 | php${PHP_VERSION//.}-${{ matrix.variant }}-all
|
65 |
| - docker images --filter=reference=thecodingmachine/php >> $GITHUB_STEP_SUMMARY |
| 103 | + - name: Artifacts |
| 104 | + uses: actions/upload-artifact@v3 |
| 105 | + with: |
| 106 | + name: digests-${{ matrix.php_version }}-${{ matrix.variant }} |
| 107 | + path: /tmp/digests-php${PHP_VERSION//.}-${{ matrix.variant }}.log |
| 108 | + retention-days: 60 |
| 109 | + - name: Display tags built |
| 110 | + run: | |
| 111 | + echo "With prefix :" |
| 112 | + TAG_PREFIX="rc${GITHUB_SHA::7}-" \ |
| 113 | + docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --print --progress plain | jq ".target[].tags | join(\" \")" -r |
| 114 | + echo "-----" |
| 115 | + echo "Regular :" |
| 116 | + PHP_PATCH_MINOR="${PHP_VERSION_MINOR}" \ |
| 117 | + docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --print --progress plain | jq ".target[].tags | join(\" \")" -r |
| 118 | + |
0 commit comments