Skip to content

Commit 39e0ec2

Browse files
committed
Merge start container and http check
Signed-off-by: MadCat34 <[email protected]>
1 parent 205b6e9 commit 39e0ec2

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

.github/workflows/docker-build.yml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,19 @@ jobs:
4242
if: matrix.target.name == 'dev'
4343
run: docker run --rm laminas:${{ matrix.target.name }} vendor/bin/phpunit module/*/test
4444

45-
- name: Start container for ${{ matrix.target.name }}
46-
run: docker run --rm -d -p ${{ matrix.target.port }}:80 --name laminas-test-${{ matrix.target.name }} laminas:${{ matrix.target.name }}
47-
48-
- name: Check HTTP status
45+
- name: Start container for ${{ matrix.target.name }} and check HTTP status
4946
run: |
50-
retries=15
51-
while [ $retries -gt 0 ]; do
52-
http_status_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:${{ matrix.target.port }})
53-
response_body=$(curl -s http://localhost:${{ matrix.target.port }})
54-
if [ "$http_status_code" -eq 200 ] && [[ "$response_body" =~ "Welcome" ]]; then
55-
echo "HTTP status code: $http_status_code"
56-
echo "Response body: $response_body"
57-
break
58-
fi
59-
echo "Waiting for service to be ready..."
60-
sleep 10
61-
retries=$((retries-1))
62-
done
63-
if [ $retries -eq 0 ]; then
64-
echo "Service did not start successfully."
47+
docker run --rm -d -p ${{ matrix.target.port }}:80 --name laminas-test-${{ matrix.target.name }} laminas:${{ matrix.target.name }}
48+
http_status_code=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:${{ matrix.target.port }})
49+
response_body=$(curl -s http://localhost:${{ matrix.target.port }})
50+
if [ "$http_status_code" -eq 200 ] && [[ "$response_body" =~ "Welcome" ]]; then
6551
echo "HTTP status code: $http_status_code"
6652
echo "Response body: $response_body"
67-
exit 1
53+
else
54+
echo "Service did not start successfully."
55+
echo "HTTP status code: $http_status_code"
56+
echo "Response body: $response_body"
57+
exit 1
6858
fi
6959
7060
- name: Stop and remove container for ${{ matrix.target.name }}

0 commit comments

Comments
 (0)