|
| 1 | +--- |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: # yamllint disable-line rule:truthy |
| 8 | + pull_request: |
| 9 | + paths-ignore: |
| 10 | + - '**.md' |
| 11 | + |
| 12 | +env: |
| 13 | + DOCKER_NAMESPACE: wayofdev/php-dev |
| 14 | + GHCR_NAMESPACE: ghcr.io/wayofdev/docker-php-dev |
| 15 | + |
| 16 | +name: 🧪 Test Docker images |
| 17 | + |
| 18 | +jobs: |
| 19 | + test: |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + os_name: ["alpine"] |
| 24 | + php_version: ["8.1", "8.2", "8.3"] |
| 25 | + php_type: ["fpm", "cli", "supervisord"] |
| 26 | + builder: [{arch: "amd64", os: "ubuntu-latest"}] |
| 27 | + runs-on: ${{ matrix.builder.os }} |
| 28 | + steps: |
| 29 | + |
| 30 | + - name: 🌎 Set environment variables |
| 31 | + run: | |
| 32 | + php_version="${{ matrix.php_version }}" |
| 33 | + tag="${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-${{ matrix.builder.arch }}" |
| 34 | + php_version_slug="${php_version//./}" |
| 35 | + target="php-${php_version_slug}-${{ matrix.php_type }}-${{ matrix.os_name }}" |
| 36 | + echo "TARGET=${target}" >> $GITHUB_ENV |
| 37 | + echo "PLATFORM_CACHE_TAG=${tag}" >> $GITHUB_ENV |
| 38 | +
|
| 39 | + - name: 📦 Check out the codebase |
| 40 | + uses: actions/checkout@v4.1.1 |
| 41 | + |
| 42 | + - name: 🛠️ Install goss and dgoss |
| 43 | + uses: e1himself/goss-installation-action@v1.2.1 |
| 44 | + with: |
| 45 | + version: v0.4.6 |
| 46 | + |
| 47 | + - name: 🤖 Generate dist files |
| 48 | + run: ansible-playbook src/playbook.yml -l ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }} |
| 49 | + |
| 50 | + - name: 🖥️ Setup docker QEMU |
| 51 | + uses: docker/setup-qemu-action@v3 |
| 52 | + |
| 53 | + - name: 🛠️ Set up Docker Buildx |
| 54 | + uses: docker/setup-buildx-action@v3 |
| 55 | + with: |
| 56 | + buildkitd-flags: "--debug" |
| 57 | + |
| 58 | + - name: 🔑 Login to docker-hub |
| 59 | + uses: docker/login-action@v3 |
| 60 | + with: |
| 61 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 62 | + password: ${{ secrets.DOCKER_TOKEN }} |
| 63 | + |
| 64 | + - name: 🔑 Login to GHCR |
| 65 | + uses: docker/login-action@v3 |
| 66 | + with: |
| 67 | + registry: ghcr.io |
| 68 | + username: ${{ github.repository_owner }} |
| 69 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + |
| 71 | + - name: 🐳 Extract docker meta data |
| 72 | + id: meta |
| 73 | + uses: docker/metadata-action@v5 |
| 74 | + with: |
| 75 | + images: | |
| 76 | + ${{ env.DOCKER_NAMESPACE }} |
| 77 | + ${{ env.GHCR_NAMESPACE }} |
| 78 | + tags: | |
| 79 | + type=raw,event=branch,value=latest |
| 80 | + type=ref,event=pr |
| 81 | + type=semver,pattern={{version}} |
| 82 | + type=semver,pattern={{major}}.{{minor}} |
| 83 | + flavor: | |
| 84 | + latest=false |
| 85 | + prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}- |
| 86 | +
|
| 87 | + - name: 🧪 Bake image for testing |
| 88 | + id: bake |
| 89 | + uses: docker/bake-action@v4 |
| 90 | + with: |
| 91 | + targets: ${{ env.TARGET }} |
| 92 | + files: | |
| 93 | + ./docker-bake.hcl |
| 94 | + ${{ steps.meta.outputs.bake-file }} |
| 95 | + set: | |
| 96 | + *.tags= |
| 97 | + *.platform=linux/${{ matrix.builder.arch }} |
| 98 | + *.cache-from=type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }} |
| 99 | + *.cache-to=type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }} |
| 100 | + *.output=type=docker,"name=${{ env.DOCKER_NAMESPACE }},${{ env.GHCR_NAMESPACE }}",name-canonical=true,push=false |
| 101 | +
|
| 102 | + - name: 🧪 Test Docker image |
| 103 | + run: | |
| 104 | + export IMAGE_TEMPLATE=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }} |
| 105 | + export IMAGE_TAG=${{ env.DOCKER_NAMESPACE }}:latest |
| 106 | + make test |
0 commit comments