ci(levitate): migrate scripts to es modules

This commit is contained in:
Jack Westbrook
2025-03-03 09:43:26 +01:00
parent c6cc559b5a
commit 7c10280b7f
2 changed files with 19 additions and 17 deletions
@@ -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
@@ -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);
}
}
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