2023-11-17 02:23:08 +00:00
|
|
|
name: 'Setup WooCommerce Monorepo'
|
|
|
|
description: 'A composite action bundling together the setup of dependencies and optional installation and building of projects.'
|
2022-09-13 01:55:03 +00:00
|
|
|
inputs:
|
2023-11-17 02:23:08 +00:00
|
|
|
php-version:
|
|
|
|
description: 'The PHP version that should be installed. Use "false" to skip PHP installation.'
|
|
|
|
default: '7.4'
|
|
|
|
install:
|
|
|
|
description: 'Given a boolean or PNPM filter, runs the install command for monorepo project(s).'
|
|
|
|
default: false
|
|
|
|
build:
|
|
|
|
description: 'Given a boolean or PNPM filter, runs the build command for monorepo project(s).'
|
|
|
|
default: false
|
2022-09-13 01:55:03 +00:00
|
|
|
runs:
|
2023-11-17 02:23:08 +00:00
|
|
|
using: 'composite'
|
|
|
|
steps:
|
|
|
|
- name: 'Setup PNPM'
|
|
|
|
uses: 'pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598'
|
|
|
|
with:
|
|
|
|
version: '8'
|
|
|
|
- name: 'Setup Node'
|
|
|
|
uses: 'actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65'
|
|
|
|
with:
|
|
|
|
node-version-file: '.nvmrc'
|
|
|
|
cache: 'pnpm'
|
|
|
|
- name: 'Setup PHP'
|
2023-11-17 02:29:48 +00:00
|
|
|
if: ${{ inputs.php-version != 'false' }}
|
2023-11-17 02:23:08 +00:00
|
|
|
uses: 'shivammathur/setup-php@a36e1e52ff4a1c9e9c9be31551ee4712a6cb6bd0'
|
|
|
|
with:
|
|
|
|
php-version: '${{ inputs.php-version }}'
|
|
|
|
coverage: 'none'
|
|
|
|
tools: 'phpcs, sirbrillig/phpcs-changed:2.11.1'
|
|
|
|
- name: 'Cache Composer Dependencies'
|
2023-11-17 02:29:48 +00:00
|
|
|
if: ${{ inputs.php-version != 'false' }}
|
2023-11-17 02:23:08 +00:00
|
|
|
uses: 'actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84'
|
|
|
|
with:
|
|
|
|
path: '~/.cache/composer/files'
|
2023-11-17 02:31:49 +00:00
|
|
|
key: "${{ runner.os }}-composer-${{ hashFiles( '**/composer.lock' ) }}"
|
2023-11-17 02:23:08 +00:00
|
|
|
restore-keys: '${{ runner.os }}-composer-'
|
|
|
|
- name: 'Parse Project Filters'
|
|
|
|
id: 'project-filters'
|
2023-11-17 02:33:20 +00:00
|
|
|
shell: 'bash'
|
2023-11-17 02:23:08 +00:00
|
|
|
run: |
|
|
|
|
echo "install=$(node ./.github/actions/setup-woocommerce-monorepo/scripts/parse-input-filter.js '${{ inputs.install }}')" >> $GITHUB_OUTPUT
|
|
|
|
echo "build=$(node ./.github/actions/setup-woocommerce-monorepo/scripts/parse-input-filter.js '${{ inputs.build }}')" >> $GITHUB_OUTPUT
|
|
|
|
- name: 'Install Project Dependencies'
|
|
|
|
# Boolean inputs aren't parsed into filters so it'll either be "true" or there will be a filter.
|
|
|
|
if: ${{ inputs.install == 'true' || steps.project-filters.outputs.install != '' }}
|
2023-11-17 02:33:20 +00:00
|
|
|
shell: 'bash'
|
2023-11-17 02:23:08 +00:00
|
|
|
run: 'pnpm install ${{ steps.project-filters.outputs.install }}'
|
|
|
|
# We want to include an option to build projects using this action so that we can make
|
|
|
|
# sure that the build cache is always used when building projects.
|
|
|
|
- name: 'Cache Build Output'
|
|
|
|
# Boolean inputs aren't parsed into filters so it'll either be "true" or there will be a filter.
|
|
|
|
if: ${{ inputs.build == 'true' || steps.project-filters.outputs.build != '' }}
|
|
|
|
uses: 'google/wireit@f3a3c79c553122e2fe5829eeac7d815326502903'
|
|
|
|
- name: 'Build'
|
|
|
|
# Boolean inputs aren't parsed into filters so it'll either be "true" or there will be a filter.
|
|
|
|
if: ${{ inputs.build == 'true' || steps.project-filters.outputs.build != '' }}
|
2023-11-17 02:33:20 +00:00
|
|
|
shell: 'bash'
|
2023-11-17 02:23:08 +00:00
|
|
|
run: 'pnpm ${{ steps.project-filters.outputs.build }} build'
|