2022-11-09 16:39:22 +00:00
|
|
|
name: Highlight templates changes
|
2023-01-12 01:09:36 +00:00
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
paths-ignore:
|
|
|
|
- '**/changelog/**'
|
2023-01-02 17:28:11 +00:00
|
|
|
|
|
|
|
permissions: {}
|
|
|
|
|
2022-05-17 01:47:17 +00:00
|
|
|
jobs:
|
|
|
|
analyze:
|
|
|
|
name: Check pull request changes to highlight
|
|
|
|
runs-on: ubuntu-20.04
|
2023-01-02 17:28:11 +00:00
|
|
|
permissions:
|
2023-01-12 01:09:36 +00:00
|
|
|
contents: read
|
2022-05-17 01:47:17 +00:00
|
|
|
outputs:
|
|
|
|
results: ${{ steps.results.outputs.results }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install prerequisites
|
|
|
|
run: |
|
2022-10-02 21:52:42 +00:00
|
|
|
npm install -g pnpm
|
2022-08-16 01:21:52 +00:00
|
|
|
npm -g i @wordpress/env@5.1.0
|
2022-09-10 21:55:53 +00:00
|
|
|
pnpm install --filter code-analyzer --filter cli-core
|
2022-05-17 01:47:17 +00:00
|
|
|
- name: Run analyzer
|
|
|
|
id: run
|
2022-09-15 21:21:42 +00:00
|
|
|
working-directory: tools/code-analyzer
|
2022-08-22 04:29:59 +00:00
|
|
|
run: |
|
2022-10-25 21:36:46 +00:00
|
|
|
HEAD_REF=$(git rev-parse HEAD)
|
|
|
|
version=$(pnpm run analyzer major-minor "$HEAD_REF" "plugins/woocommerce/woocommerce.php" | tail -n 1)
|
|
|
|
pnpm run analyzer "$HEAD_REF" $version -o "github"
|
2022-11-09 16:39:22 +00:00
|
|
|
- name: Check results
|
|
|
|
uses: actions/github-script@v6
|
2022-05-17 01:47:17 +00:00
|
|
|
with:
|
2023-01-12 01:09:36 +00:00
|
|
|
script: |
|
|
|
|
const template = '${{ steps.run.outputs.templates }}';
|
2022-11-09 16:39:22 +00:00
|
|
|
|
2023-01-12 01:09:36 +00:00
|
|
|
if ( template === '' ) {
|
|
|
|
return;
|
|
|
|
}
|
2022-11-09 16:39:22 +00:00
|
|
|
|
2023-01-12 01:09:36 +00:00
|
|
|
const templateArr = template.split( '\n' );
|
|
|
|
const modTemplateArr = [];
|
|
|
|
let needsVersionBump = false;
|
2022-11-09 16:39:22 +00:00
|
|
|
|
2023-01-12 01:09:36 +00:00
|
|
|
templateArr.forEach( ( el ) => {
|
|
|
|
if ( el.match( /NOTICE/ ) ) {
|
|
|
|
modTemplateArr.pop();
|
|
|
|
return;
|
|
|
|
}
|
2022-11-09 16:39:22 +00:00
|
|
|
|
2023-01-12 01:09:36 +00:00
|
|
|
if ( el.match( /WARNING/ ) ) {
|
|
|
|
needsVersionBump = true;
|
|
|
|
}
|
2022-11-09 16:39:22 +00:00
|
|
|
|
2023-01-12 01:09:36 +00:00
|
|
|
modTemplateArr.push( el );
|
|
|
|
} );
|
2022-11-09 16:39:22 +00:00
|
|
|
|
2023-01-12 01:09:36 +00:00
|
|
|
const templateResult = modTemplateArr.join( '\n' );
|
2022-11-09 16:39:22 +00:00
|
|
|
|
2023-01-12 01:09:36 +00:00
|
|
|
if ( needsVersionBump ) {
|
|
|
|
core.setFailed( `Templates have changed but template versions were not bumped:\n${ templateResult }` );
|
|
|
|
}
|