-
Notifications
You must be signed in to change notification settings - Fork 1
executable file
·134 lines (114 loc) · 3.38 KB
/
phpapp.yml
File metadata and controls
executable file
·134 lines (114 loc) · 3.38 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: PHP CI/CD
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: phpapp
MYSQL_ROOT_PASSWORD: root
MYSQL_ROOT_HOST: "%"
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -u root -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, intl, mysqli, zip
coverage: none
tools: composer:v2
ini-values: |
opcache.enable=1
opcache.enable_cli=1
opcache.jit=0
display_errors=On
display_startup_errors=On
error_reporting=E_ALL
- name: Check PHP installation
run: |
php -v
php -m
php --ini
- name: Validate composer.json
run: composer validate --strict
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Create .env file
run: |
cp .env.example .env
sed -i 's/^DB_HOST=.*/DB_HOST=127.0.0.1/' .env
sed -i 's/^DB_DATABASE=.*/DB_DATABASE=phpapp/' .env
sed -i 's/^DB_USERNAME=.*/DB_USERNAME=root/' .env
sed -i 's/^DB_PASSWORD=.*/DB_PASSWORD=root/' .env
- name: Verify project structure
run: |
echo "Current directory structure:"
ls -la
if [ -d "public" ]; then
echo "Contents of public directory:"
ls -la public
else
echo "public directory not found!"
echo "Contents of root directory:"
ls -la
fi
- name: Start PHP server
run: |
# Determine the correct document root
if [ -d "public" ]; then
DOCROOT="public"
elif [ -d "www" ]; then
DOCROOT="www"
else
DOCROOT="."
fi
echo "Using document root: $DOCROOT"
# Start PHP server with error logging
php -S 127.0.0.1:8000 -t $DOCROOT > php-server.log 2>&1 &
echo $! > php-server.pid
# Give it a moment to start
sleep 2
# Check if process is running
if ps -p $(cat php-server.pid) > /dev/null; then
echo "PHP server process is running"
else
echo "PHP server failed to start"
cat php-server.log
exit 1
fi
- name: Wait for server and check health
run: |
max_attempts=30
attempt=1
while [ $attempt -le $max_attempts ]; do
echo "Attempt $attempt of $max_attempts"
if curl -s -f http://127.0.0.1:8000 > /dev/null 2>&1; then
echo "Server is responding!"
exit 0
fi
# Check if server is still running
if ! ps -p $(cat php-server.pid) > /dev/null; then
echo "PHP server has died. Server log:"
cat php-server.log
exit 1
fi
sleep 1
attempt=$((attempt + 1))
done
echo "Server failed to respond after $max_attempts attempts"
echo "PHP Server log:"
cat php-server.log
exit 1