diff --git a/.github/workflows/detect-breaking-changes-levitate.yml b/.github/workflows/detect-breaking-changes-levitate.yml index 70c823483d9..63ded1bf9d7 100644 --- a/.github/workflows/detect-breaking-changes-levitate.yml +++ b/.github/workflows/detect-breaking-changes-levitate.yml @@ -202,7 +202,7 @@ jobs: with: script: | const filePath = 'result.json'; - const script = require('./.github/workflows/scripts/json-file-to-job-output.js'); + const { default: script } = await import ('${{ github.workspace }}/.github/workflows/scripts/json-file-to-job-output.js') await script({ core, filePath }); # Check if label exists diff --git a/.github/workflows/scripts/json-file-to-job-output.js b/.github/workflows/scripts/json-file-to-job-output.js index c71c1b86001..e03385dd97a 100644 --- a/.github/workflows/scripts/json-file-to-job-output.js +++ b/.github/workflows/scripts/json-file-to-job-output.js @@ -1,18 +1,20 @@ -module.exports = async ({ core, filePath }) => { - try { - const fs = require('fs').promises; - const content = await fs.readFile(filePath) - const result = JSON.parse(content); - - core.startGroup('Parsing json file...'); +const jsonToJobOutput = async ({ core, filePath }) => { + try { + const fs = await import('fs/promises'); + const content = await fs.readFile(filePath) + const result = JSON.parse(content); - for (const property in result) { - core.info(`${property} <- ${result[property]}`); - core.setOutput(property, result[property]); - } + core.startGroup('Parsing json file...'); - core.endGroup(); - } catch (error) { - core.setFailed(error.message); - } -} \ No newline at end of file + for (const property in result) { + core.info(`${property} <- ${result[property]}`); + core.setOutput(property, result[property]); + } + + core.endGroup(); + } catch (error) { + core.setFailed(error.message); + } +} + +export default jsonToJobOutput