From 98173be3f065603a9854ceb8b82ad75b7eb30bfe Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Mon, 3 Apr 2023 19:39:22 +0100 Subject: [PATCH] Add a comment about `lib/defaults.json` --- .github/actions/update-bundle/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/actions/update-bundle/index.ts b/.github/actions/update-bundle/index.ts index 05a339253..a8bd13e27 100644 --- a/.github/actions/update-bundle/index.ts +++ b/.github/actions/update-bundle/index.ts @@ -34,19 +34,19 @@ function getCodeQLCliVersionForRelease(release): string { } return cliVersionsFromMarkerFiles[0]; } - + async function getBundleInfoFromRelease(release): Promise { return { bundleVersion: release.tag_name.substring(CODEQL_BUNDLE_PREFIX.length), cliVersion: getCodeQLCliVersionForRelease(release) }; } - + async function getNewDefaults(currentDefaults: Defaults): Promise { const release = github.context.payload.release; console.log('Updating default bundle as a result of the following release: ' + `${JSON.stringify(release)}.`) - + const bundleInfo = await getBundleInfoFromRelease(release); return { bundleVersion: bundleInfo.bundleVersion, @@ -55,14 +55,15 @@ function getCodeQLCliVersionForRelease(release): string { priorCliVersion: currentDefaults.cliVersion }; } - + async function main() { const previousDefaults: Defaults = JSON.parse(fs.readFileSync('../../../src/defaults.json', 'utf8')); const newDefaults = await getNewDefaults(previousDefaults); + // Update the source file in the repository. Calling workflows should subsequently rebuild + // the Action to update `lib/defaults.json`. fs.writeFileSync('../../../src/defaults.json', JSON.stringify(newDefaults, null, 2) + "\n"); } - + // Ideally, we'd await main() here, but that doesn't work well with `ts-node`. // So instead we rely on the fact that Node won't exit until the event loop is empty. main(); - \ No newline at end of file