84d0232095
Monica now depends on PHP 8.0+
103 lines
2.9 KiB
YAML
103 lines
2.9 KiB
YAML
name: Build
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
branches-ignore: ['l10n_main*']
|
|
release:
|
|
types: [created]
|
|
|
|
workflow_run:
|
|
workflows: ['Compress images']
|
|
types: [completed]
|
|
|
|
env:
|
|
php-version: '8.1'
|
|
node-version: 16
|
|
|
|
jobs:
|
|
#############
|
|
# Build
|
|
#############
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
name: Build Assets
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
|
|
steps:
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup PHP ${{ env.php-version }}
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ env.php-version }}
|
|
extensions: redis
|
|
coverage: none
|
|
- name: Check PHP Version
|
|
run: php -v
|
|
- name: Check Composer Version
|
|
run: composer -V
|
|
- name: Check PHP Extensions
|
|
run: php -m
|
|
|
|
# Composer
|
|
- name: Validate composer.json and composer.lock
|
|
run: composer validate
|
|
|
|
- name: Get Composer Cache Directory
|
|
id: composer-cache
|
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
|
- name: Cache composer files
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ steps.composer-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-composer-${{ env.php-version }}-${{ hashFiles('**/composer.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-composer-${{ env.php-version }}-${{ hashFiles('**/composer.lock') }}
|
|
${{ runner.os }}-composer-${{ env.php-version }}
|
|
${{ runner.os }}-composer-
|
|
|
|
- name: Install composer dependencies
|
|
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
|
|
|
|
# Yarn
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ env.node-version }}
|
|
- name: Get yarn cache directory path
|
|
id: yarn-cache
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
- name: Cache yarn files
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ steps.yarn-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
${{ runner.os }}-yarn-
|
|
|
|
- name: Install yarn dependencies
|
|
run: yarn inst
|
|
- name: Lint files
|
|
run: yarn run lint:all
|
|
- name: Build assets
|
|
run: yarn run production
|
|
|
|
- name: Check if there is any file update needed
|
|
id: check
|
|
run: |
|
|
status=$(git status --porcelain)
|
|
if [ -z "$status" ]; then
|
|
echo "Nothing to push, already up to date."
|
|
else
|
|
echo -e "Waiting modifications:\n$status"
|
|
echo "::error::Assets are not up to date. Please rebuild with: 'yarn run lint:all' and 'yarn run prod'."
|
|
exit -1
|
|
fi
|