Repository navigation
73 lines (62 loc) · 2.27 KB
/
Copy pathci.yaml
File metadata and controls
73 lines (62 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: ci
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- version: 7.4
dockerfile: apache/7.4/Dockerfile
tag: sarkedev/php:7.4-apache
- version: 8.4
dockerfile: apache/8.4/Dockerfile
tag: sarkedev/php:8.4-apache
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
submodules: recursive
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build Docker image for PHP ${{ matrix.version }}
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
load: true
tags: ${{ matrix.tag }}
cache-from: type=registry,ref=${{ matrix.tag }}
cache-to: type=inline
- name: Smoke test PHP ${{ matrix.version }} image
run: |
set -eu
image="${{ matrix.tag }}"
name="php-smoke-${{ matrix.version }}"
trap 'status=$?; if [ "$status" -ne 0 ]; then docker logs "$name" 2>&1 || true; fi; docker rm -f "$name" >/dev/null 2>&1 || true' EXIT
docker run -d --name "$name" -p 127.0.0.1:8080:80 "$image"
docker exec "$name" sh -ec 'mkdir -p /app/web && printf "<?php echo PHP_VERSION;" > /app/web/smoke.php'
for attempt in $(seq 1 30); do
if output="$(curl --fail --silent --connect-timeout 1 --max-time 2 http://127.0.0.1:8080/smoke.php)"; then
printf 'HTTP PHP version: %s\n' "$output"
case "$output" in
"${{ matrix.version }}".*) exit 0 ;;
*) printf 'Expected PHP ${{ matrix.version }}, got %s\n' "$output" >&2; exit 1 ;;
esac
fi
sleep 1
done
printf 'Apache/PHP smoke test timed out for %s\n' "$image" >&2
exit 1
- name: Push verified PHP ${{ matrix.version }} image
run: docker push "${{ matrix.tag }}"