Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Set up a GitHub Actions workflow #5

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Main

on:
push:
branches: [ main, wip ]
pull_request:
branches: [ main ]
schedule:
# Every twelve (12) hours.
# @see https://crontab.guru/every-12-hours
- cron: 0 */12 * * *
workflow_dispatch:

jobs:
build:
runs-on: "${{ matrix.os }}-latest"
strategy:
fail-fast: false
matrix:
os: [ ubuntu ]
php: [ 8.1, 8.2, 8.3 ]

steps:
- name: Checkout code
uses: actions/checkout@v4 # https://github.com/marketplace/actions/checkout

- name: Set up PHP CLI
uses: shivammathur/setup-php@v2 # https://github.com/marketplace/actions/setup-php-action
with:
php-version: "${{ matrix.php }}"

- name: Create project
run: |
set -o xtrace

# Prepare the target directory.
sudo mkdir -p /var/www
sudo rm -rf /var/www/*
sudo chmod 777 /var/www
TravisCarden marked this conversation as resolved.
Show resolved Hide resolved

# Create the project.
git checkout -b main
composer create-project \
--stability=dev \
--repository='{"type":"vcs","url":"'"$(pwd)"'"}' \
--ansi \
drupal/starshot-project \
/var/www
cd /var/www

# Enable verbose error logging (debug mode).
./vendor/bin/drush config:set --yes system.logging error_level verbose
./vendor/bin/drush config:get system.logging error_level

# @todo The above Drush command doesn't ultimately take effect
# for some reason. Manually change the settings until it can
# be debugged.
echo "if (file_exists(__DIR__ . '/settings.local.php')) {
include __DIR__ . '/settings.local.php';
}" | sudo tee -a web/sites/default/settings.php
sudo cp web/sites/example.settings.local.php \
web/sites/default/settings.local.php

# Make everything writable.
sudo chmod -R 777 /var/www/web

- name: Set up Apache on Linux
if: runner.os == 'Linux'
run: |
set -o xtrace

# Install Apache w/ PHP.
sudo add-apt-repository ppa:ondrej/php
sudo add-apt-repository ppa:ondrej/apache2
sudo apt update
sudo apt install \
apache2 \
php${{ matrix.php }} \
libapache2-mod-php${{ matrix.php }}
sudo a2enmod php${{ matrix.php }}

# Change the default site web directory.
sudo sed -i 's/\/var\/www\/html/\/var\/www\/web/g' /etc/apache2/sites-enabled/000-default.conf

# Start the service.
sudo service apache2 start
TravisCarden marked this conversation as resolved.
Show resolved Hide resolved

- name: Debugging
if: runner.os == 'macOS'
run: |
php -v | head -1
php --ini

- name: Test
run: |
set -o xtrace

php /var/www/vendor/bin/drush core:status
curl http://localhost/ 2>/dev/null
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"post-create-project-cmd": [
"@drupal:install",
"Composer\\Config::disableProcessTimeout",
"@php web/core/scripts/drupal quick-start"
"test -n \"$CI\" || php -d max_execution_time=0 web/core/scripts/drupal quick-start"
]
},
"scripts-descriptions": {
Expand Down