From 910f765176b53987f6827ddb550e1016a307f03e Mon Sep 17 00:00:00 2001 From: AlecGlen Date: Sat, 24 Sep 2022 16:45:22 -0500 Subject: [PATCH] Check for original data changes before running post-processing --- src/main.ts | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main.ts b/src/main.ts index cc049ef..84e0ac2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -61,17 +61,25 @@ async function run(): Promise { if (config.postprocess) { core.startGroup('Postprocess') - core.debug(`Invoking ${config.postprocess} with ${filename}...`) - try { - const raw = execSync( - `NO_COLOR=true deno run -q --allow-read --allow-write --allow-run --allow-net --allow-env --unstable ${config.postprocess} ${filename}` - ).toString() - - core.info('Deno output:') - core.info(raw) - } catch (error) { - core.setFailed(error) + + const changes = await execSync(`git diff ${filename}`).toString() + if (changes.length > 0) { + core.debug(`Invoking ${config.postprocess} with ${filename}...`) + try { + const raw = execSync( + `NO_COLOR=true deno run -q --allow-read --allow-write --allow-run --allow-net --allow-env --unstable ${config.postprocess} ${filename}` + ).toString() + + core.info('Deno output:') + core.info(raw) + } catch (error) { + core.setFailed(error) + } + } else { + core.debug(`Skipping ${config.postprocess} because there were no changes to ${filename}.`) } + + core.endGroup() }