60 lines
1.8 KiB
YAML
60 lines
1.8 KiB
YAML
name: 'Highlight Template Changes'
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'plugins/woocommerce/**'
|
|
jobs:
|
|
analyze:
|
|
name: 'Analyze Branch Changes'
|
|
runs-on: 'ubuntu-20.04'
|
|
outputs:
|
|
results: ${{ steps.results.outputs.results }}
|
|
steps:
|
|
- uses: 'actions/checkout@v3'
|
|
name: 'Checkout'
|
|
- uses: './.github/actions/setup-woocommerce-monorepo'
|
|
name: 'Setup WooCommerce Monorepo'
|
|
with:
|
|
install: 'code-analyzer...'
|
|
build: 'code-analyzer'
|
|
- name: 'Analyze'
|
|
id: 'analyze'
|
|
working-directory: 'tools/code-analyzer'
|
|
run: |
|
|
HEAD_REF=$(git rev-parse HEAD)
|
|
exclude="plugins/woocommerce/tests plugins/woocommerce-admin/tests plugins/woocommerce-blocks/tests"
|
|
version=$(pnpm analyzer major-minor "$HEAD_REF" "plugins/woocommerce/woocommerce.php" | tail -n 1)
|
|
pnpm analyzer "$HEAD_REF" $version -o "github" -e $exclude
|
|
- uses: 'actions/github-script@v6'
|
|
name: 'Validate'
|
|
with:
|
|
script: |
|
|
const template = '${{ steps.analyze.outputs.templates }}';
|
|
|
|
if ( template === '' ) {
|
|
return;
|
|
}
|
|
|
|
const templateArr = template.split( '\n' );
|
|
const modTemplateArr = [];
|
|
let needsVersionBump = false;
|
|
|
|
templateArr.forEach( ( el ) => {
|
|
if ( el.match( /NOTICE/ ) ) {
|
|
modTemplateArr.pop();
|
|
return;
|
|
}
|
|
|
|
if ( el.match( /WARNING/ ) ) {
|
|
needsVersionBump = true;
|
|
}
|
|
|
|
modTemplateArr.push( el );
|
|
} );
|
|
|
|
const templateResult = modTemplateArr.join( '\n' );
|
|
|
|
if ( needsVersionBump ) {
|
|
core.setFailed( `Templates have changed but template versions were not bumped:\n${ templateResult }` );
|
|
}
|