2022-09-13 01:55:03 +00:00
|
|
|
name: Setup WooCommerce Monorepo
|
|
|
|
description: Handles the installation, building, and caching of the projects within the monorepo.
|
2023-01-02 17:28:11 +00:00
|
|
|
permissions: {}
|
2022-09-13 01:55:03 +00:00
|
|
|
|
|
|
|
inputs:
|
2023-10-19 18:24:20 +00:00
|
|
|
install:
|
|
|
|
description: Indicates whether or not the action should install any projects.
|
|
|
|
default: 'true'
|
2022-12-05 20:35:49 +00:00
|
|
|
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'
|
2022-09-13 01:55:03 +00:00
|
|
|
|
|
|
|
runs:
|
2022-12-05 20:35:49 +00:00
|
|
|
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
|
2022-09-13 01:55:03 +00:00
|
|
|
|
2022-12-05 20:35:49 +00:00
|
|
|
- name: Setup PNPM
|
2023-01-24 02:44:31 +00:00
|
|
|
uses: pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd
|
2022-12-05 20:35:49 +00:00
|
|
|
with:
|
2023-07-18 02:27:18 +00:00
|
|
|
version: '8.6.7'
|
2022-09-13 01:55:03 +00:00
|
|
|
|
2022-12-05 20:35:49 +00:00
|
|
|
- name: Setup Node
|
2023-01-27 07:26:54 +00:00
|
|
|
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
|
2022-12-05 20:35:49 +00:00
|
|
|
with:
|
|
|
|
node-version-file: .nvmrc
|
|
|
|
cache: pnpm
|
|
|
|
registry-url: 'https://registry.npmjs.org'
|
2022-09-13 01:55:03 +00:00
|
|
|
|
2022-12-05 20:35:49 +00:00
|
|
|
- name: Setup PHP
|
2023-01-27 07:26:54 +00:00
|
|
|
uses: shivammathur/setup-php@8e2ac35f639d3e794c1da1f28999385ab6fdf0fc
|
2022-12-05 20:35:49 +00:00
|
|
|
with:
|
|
|
|
php-version: ${{ inputs.php-version }}
|
|
|
|
coverage: none
|
2023-06-21 02:09:28 +00:00
|
|
|
tools: phpcs, sirbrillig/phpcs-changed:2.11.1
|
2022-09-13 01:55:03 +00:00
|
|
|
|
2022-12-05 20:35:49 +00:00
|
|
|
- name: Cache Composer Dependencies
|
2023-04-28 04:34:49 +00:00
|
|
|
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
|
2022-12-05 20:35:49 +00:00
|
|
|
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-
|
2022-09-13 01:55:03 +00:00
|
|
|
|
2022-12-05 20:35:49 +00:00
|
|
|
- name: Install Node and PHP Dependencies
|
|
|
|
shell: bash
|
2023-10-19 18:24:20 +00:00
|
|
|
if: ${{ inputs.install == 'true' }}
|
|
|
|
env:
|
|
|
|
PUPPETEER_SKIP_DOWNLOAD: 'true'
|
2022-12-05 20:35:49 +00:00
|
|
|
run: |
|
|
|
|
pnpm -w install turbo
|
|
|
|
pnpm install ${{ steps.parse-input.outputs.INSTALL_FILTERS }}
|
2022-09-13 01:55:03 +00:00
|
|
|
|
2023-04-28 04:34:49 +00:00
|
|
|
- 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
|
|
|
|
|
2022-12-05 20:35:49 +00:00
|
|
|
- name: Cache Build Output
|
2023-10-19 18:24:20 +00:00
|
|
|
if: ${{ inputs.build == 'true' }}
|
2023-04-28 04:34:49 +00:00
|
|
|
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
|
2022-12-05 20:35:49 +00:00
|
|
|
with:
|
2023-04-28 04:34:49 +00:00
|
|
|
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
|
2022-12-05 20:35:49 +00:00
|
|
|
|
|
|
|
- name: Build
|
2023-10-19 18:24:20 +00:00
|
|
|
if: ${{ inputs.install == 'true' && inputs.build == 'true' }}
|
2022-12-05 20:35:49 +00:00
|
|
|
shell: bash
|
2023-04-28 04:34:49 +00:00
|
|
|
run: pnpm -w exec turbo run turbo:build --cache-dir=".turbo" ${{ steps.parse-input.outputs.BUILD_FILTERS }}
|