-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
52 lines (52 loc) · 2.64 KB
/
action.yml
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
name: 'Apache PHP'
description: 'Use after shivammathur/setup-php to use Apache. Logs will be written to the working directory.'
inputs:
php-version:
description: 'Setup PHP version. Must match the PHP version used by shivammathur/setup-php'
required: true
site-directory:
description: 'The site directory for Apache to serve'
required: true
http-port:
description: 'The port for Apache to listen to HTTP requests'
default: 8888\
# Install Apache and configure to serve the site under test. Apache is run
# in the foreground using the same user as the test runner to avoid common
# pitfalls with file ownership.
runs:
using: "composite"
steps:
- name: Install Apache with mod_php
run: |
LC_ALL=C.UTF-8 sudo apt-add-repository http://ppa.launchpad.net/ondrej/php/ubuntu
sudo apt install libapache2-mod-php${{ inputs.php-version }}
sudo a2enmod php${{ inputs.php-version }} rewrite
shell: bash
- name: Configure the site under test
run: |
echo "<Directory ${{ inputs.site-directory }}>" | sudo tee /etc/apache2/sites-available/sut.conf
echo ' Options Indexes FollowSymLinks' | sudo tee -a /etc/apache2/sites-available/sut.conf
echo ' AllowOverride all' | sudo tee -a /etc/apache2/sites-available/sut.conf
echo ' Require all granted' | sudo tee -a /etc/apache2/sites-available/sut.conf
echo '</Directory>' | sudo tee -a /etc/apache2/sites-available/sut.conf
echo '' | sudo tee -a /etc/apache2/sites-available/sut.conf
echo "<VirtualHost *:${{ inputs.http-port }}>" | sudo tee -a /etc/apache2/sites-available/sut.conf
echo ' ServerAdmin admin@localhost' | sudo tee -a /etc/apache2/sites-available/sut.conf
echo " DocumentRoot ${{ inputs.site-directory }}" | sudo tee -a /etc/apache2/sites-available/sut.conf
echo ' ErrorLog ${APACHE_LOG_DIR}/error.log' | sudo tee -a /etc/apache2/sites-available/sut.conf
echo ' CustomLog ${APACHE_LOG_DIR}/access.log combined' | sudo tee -a /etc/apache2/sites-available/sut.conf
echo '</VirtualHost>' | sudo tee -a /etc/apache2/sites-available/sut.conf
sudo sed -ri -e "s!Listen 80!Listen ${{ inputs.http-port }}!g" /etc/apache2/ports.conf
sudo a2ensite sut
sudo a2dissite 000-default
shell: bash
- name: Start Apache in the foreground
run: |
source /etc/apache2/envvars
export APACHE_LOG_DIR="${PWD}"
export APACHE_LOCK_DIR="${PWD}"
export APACHE_PID_FILE="${PWD}/apache2.pid"
nohup apache2 -DFOREGROUND > /dev/null 2>&1 &
sleep 2
nc -z "127.0.0.1" "${{ inputs.http-port }}"
shell: bash