From 39d865bd578770bf4d6963256af5d64ebd35608d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20Ainsworth?= Date: Thu, 21 Nov 2024 12:57:58 +0100 Subject: [PATCH] Parse list of files from GitHub actions --- .github/scripts/fixTranslations.mjs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/scripts/fixTranslations.mjs b/.github/scripts/fixTranslations.mjs index d3d096b44..8110e6a20 100644 --- a/.github/scripts/fixTranslations.mjs +++ b/.github/scripts/fixTranslations.mjs @@ -129,14 +129,6 @@ function fixMdocContent(content, locale) { return content; } -const modifiedFiles = []; - -// Get the list of modified files in the current PR -function getModifiedFiles() { - const output = execSync("git diff --name-only HEAD~1", { encoding: "utf-8" }); - return output.split("\n").filter((file) => file.trim() !== ""); -} - // Format MDX files using Prettier async function formatMdxFile(file) { return new Promise((resolve, reject) => { @@ -179,7 +171,6 @@ async function processFile(file, locale) { if (finalContent !== originalContent) { await fs.writeFile(file, finalContent, "utf-8"); - modifiedFiles.push(file); // Format the file after writing changes if (file.endsWith(".mdx")) { @@ -190,9 +181,9 @@ async function processFile(file, locale) { } } -// Main function to process only modified files +// Main function to process only modified files passed from the GitHub Actions workflow async function main() { - const files = getModifiedFiles(); + const files = process.argv.slice(2); console.log("Modified files:", files); for (const locale of locales) { @@ -205,8 +196,8 @@ async function main() { } } - if (modifiedFiles.length > 0) { - console.log("Processed files:", modifiedFiles.join(", ")); + if (files.length > 0) { + console.log("Processed files:", files.join(", ")); } else { console.log("No relevant files were modified."); }