diff --git a/expire-old-content.js b/expire-old-content.js index a7bc7e8..a93c69b 100644 --- a/expire-old-content.js +++ b/expire-old-content.js @@ -122,20 +122,20 @@ function updateCronSchedule() { fs.writeFileSync(workflowPath, workflowContent, 'utf8'); console.log('Workflow cron schedule updated.'); - return workflowContent == oldWorkflowContent + return workflowContent !== oldWorkflowContent } // Step 3: Commit and push changes if any files were modified -function commitAndPushChanges(hasComponentChanges) { +function commitAndPushChanges(hasChanges) { if (process.env.TARGET_BRANCH === undefined) { console.error('TARGET_BRANCH is not set. Not committing or pushing changes.'); return; } try { - if (hasComponentChanges) { - execSync(`git config user.email "41898282+github-actions[bot]@users.noreply.github.com"`); - execSync(`git config user.name "Anti-Social Bot"`); - execSync(`git add .`); + if (hasChanges) { + execSync(`git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"`); + execSync(`git config --global user.name "Anti-Social Bot"`); + execSync(`git add ${path.resolve(componentPath)} ${path.resolve(workflowPath)}`); execSync(`git commit -m "Remove expired images and update cron schedule"`); execSync(`git push origin HEAD:${process.env.TARGET_BRANCH}`); console.log('Changes pushed to repository.');