Branch to test sadow pr 41200 #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
npm -g i @wordpress/[email protected] | |
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) | |
version=$(pnpm run analyzer major-minor "$HEAD_REF" "plugins/woocommerce/woocommerce.php" | tail -n 1) | |
pnpm run 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 }` ); | |
} |