69 lines
2.0 KiB
YAML
69 lines
2.0 KiB
YAML
name: 'Highlight Template Changes'
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'plugins/woocommerce/**/templates/**/*.php'
|
|
- '!plugins/woocommerce/tests/**'
|
|
- '.github/workflows/pr-highlight-changes.yml'
|
|
branches:
|
|
- 'trunk'
|
|
|
|
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'
|
|
pull-package-deps: 'code-analyzer'
|
|
|
|
- name: 'Analyze'
|
|
id: 'analyze'
|
|
working-directory: 'tools/code-analyzer'
|
|
env:
|
|
GIT_CLONE_PROTECTION_ACTIVE: false
|
|
run: |
|
|
HEAD_REF=$(git rev-parse HEAD)
|
|
exclude="plugins/woocommerce/tests"
|
|
version=$(pnpm analyzer major-minor "$HEAD_REF" "plugins/woocommerce/woocommerce.php" | tail -n 1)
|
|
pnpm analyzer "$HEAD_REF" $version --outputStyle "github" --exclude $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 }` );
|
|
}
|