Skip to content

Commit dd5d9ac

Browse files
authored
Add basic build and install workflow (#6)
* Add workflow and fix services * Use mysql * Trick env detector into thinking were in a known CI env * toying with settings * Remove debug * cleanup * Run on schedule too
1 parent be70f81 commit dd5d9ac

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

.github/workflows/build-install.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# GitHub Action for Drupal with MySQL
2+
name: Compose and install Drupal CMS
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '1 0 * * *'
8+
jobs:
9+
symfony:
10+
name: Drupal (PHP ${{ matrix.php-versions }})
11+
runs-on: ubuntu-latest
12+
13+
# Docs: https://docs.github.com/en/actions/using-containerized-services
14+
services:
15+
mysql:
16+
image: mysql:5.7
17+
env:
18+
MYSQL_ALLOW_EMPTY_PASSWORD: false
19+
MYSQL_ROOT_PASSWORD: root
20+
MYSQL_DATABASE: root
21+
ports:
22+
- 3306/tcp
23+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
php-versions: ['8.3']
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
# Docs: https://github.com/shivammathur/setup-php
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: ${{ matrix.php-versions }}
37+
tools: phpunit-bridge
38+
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
39+
coverage: xdebug
40+
41+
# Local MySQL service in GitHub hosted environments is disabled by default.
42+
# If you are using it instead of service containers, make sure you start it.
43+
# - name: Start mysql service
44+
# run: sudo systemctl start mysql.service
45+
46+
- name: Start mysql service
47+
run: |
48+
sudo systemctl start mysql.service
49+
mysql -e 'CREATE USER "drupal"@"127.0.0.1" IDENTIFIED BY "drupal";' -uroot -proot
50+
mysql -e 'CREATE DATABASE drupal;' -uroot -proot
51+
mysql -e 'GRANT ALL PRIVILEGES ON drupal . * TO "drupal"@"127.0.0.1";' -uroot -proot
52+
53+
- name: Get composer cache directory
54+
id: composer-cache
55+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
56+
57+
- name: Cache composer dependencies
58+
uses: actions/cache@v3
59+
with:
60+
path: ${{ steps.composer-cache.outputs.dir }}
61+
# Use composer.json for key, if composer.lock is not committed.
62+
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
63+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
64+
restore-keys: ${{ runner.os }}-composer-
65+
66+
- name: Install Composer dependencies
67+
run: composer install --no-progress --prefer-dist --optimize-autoloader
68+
69+
- name: Install Drupal
70+
run: ./vendor/bin/drush site:install

0 commit comments

Comments
 (0)