woocommerce/.github/actions/setup-woocommerce-monorepo/action.yml

92 lines
3.7 KiB
YAML
Raw Normal View History

name: Setup WooCommerce Monorepo
description: Handles the installation, building, and caching of the projects within the monorepo.
permissions: {}
inputs:
install:
description: Indicates whether or not the action should install any projects.
default: 'true'
install-filters:
description: The PNPM filter used to decide what projects to install. Supports multiline strings for multiple filters.
default: ''
build:
description: Indicates whether or not the action should build any projects.
default: 'true'
build-filters:
description: The PNPM filter used to decide what projects to build. Supports multiline strings for multiple filters.
default: ''
php-version:
description: The version of PHP that the action should set up.
default: '7.4'
runs:
using: composite
steps:
- name: Parse Action Input
id: parse-input
shell: bash
run: |
echo "INSTALL_FILTERS=$(node ./.github/actions/setup-woocommerce-monorepo/scripts/parse-input-filter.js '${{ inputs.install-filters }}')" >> $GITHUB_OUTPUT
echo "BUILD_FILTERS=$(node ./.github/actions/setup-woocommerce-monorepo/scripts/parse-input-filter.js '${{ inputs.build-filters }}')" >> $GITHUB_OUTPUT
- name: Setup PNPM
uses: pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd
with:
version: '8.6.7'
- name: Setup Node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
with:
node-version-file: .nvmrc
cache: pnpm
registry-url: 'https://registry.npmjs.org'
- name: Setup PHP
uses: shivammathur/setup-php@8e2ac35f639d3e794c1da1f28999385ab6fdf0fc
with:
php-version: ${{ inputs.php-version }}
coverage: none
tools: phpcs, sirbrillig/phpcs-changed:2.11.1
- name: Cache Composer Dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: ~/.cache/composer/files
key: ${{ runner.os }}-php-${{ inputs.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-php-${{ inputs.php-version }}-composer-
- name: Install Node and PHP Dependencies
shell: bash
if: ${{ inputs.install == 'true' }}
env:
PUPPETEER_SKIP_DOWNLOAD: 'true'
run: |
pnpm -w install turbo
pnpm install ${{ steps.parse-input.outputs.INSTALL_FILTERS }}
- name: Get branch name
id: get_branch
shell: bash
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
branch_name=$(echo "${{ github.head_ref }}" | tr '/' '-')
echo "CURRENT_BRANCH_NAME=$branch_name" >> $GITHUB_OUTPUT
else
echo "CURRENT_BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
- name: Cache Build Output
if: ${{ inputs.build == 'true' }}
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: .turbo
key: ${{ runner.os }}-build-output-${{ steps.get_branch.outputs.CURRENT_BRANCH_NAME }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-output-${{ steps.get_branch.outputs.CURRENT_BRANCH_NAME }}
${{ runner.os }}-build-output
- name: Build
if: ${{ inputs.install == 'true' && inputs.build == 'true' }}
shell: bash
run: pnpm -w exec turbo run turbo:build --cache-dir=".turbo" ${{ steps.parse-input.outputs.BUILD_FILTERS }}