woocommerce/.github/workflows/pr-highlight-changes.yml

65 lines
2.2 KiB
YAML
Raw Normal View History

name: Highlight templates changes
on:
pull_request:
paths-ignore:
- '**/changelog/**'
permissions: {}
jobs:
analyze:
if: ${{ github.event.pull_request.user.login != 'github-actions[bot]' }}
name: Check pull request changes to highlight
runs-on: ubuntu-20.04
permissions:
contents: read
outputs:
results: ${{ steps.results.outputs.results }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install prerequisites
run: |
npm install -g pnpm
2023-05-26 22:48:48 +00:00
npm -g i @wordpress/env@8.0.0
pnpm install --filter code-analyzer --filter monorepo-utils
- name: Run analyzer
id: run
working-directory: tools/code-analyzer
run: |
HEAD_REF=$(git rev-parse HEAD)
2023-11-28 22:50:43 +00:00
version=$(pnpm analyzer major-minor "$HEAD_REF" "plugins/woocommerce/woocommerce.php" | tail -n 1)
pnpm analyzer "$HEAD_REF" $version -o "github"
- name: Check results
uses: actions/github-script@v6
with:
script: |
const template = '${{ steps.run.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 }` );
}