Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 84db292

Browse files
committed
Throw a ConfigurationError if JOB_RUN_UUID is already set in init action
1 parent 0002951 commit 84db292

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/init-action.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/init-action.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ async function run() {
201201
? await loadPropertiesFromApi(gitHubVersion, logger, repositoryNwo)
202202
: {};
203203

204+
// Store the previous value of `JOB_RUN_UUID`, if any.
205+
const previousJobRunUuid = process.env[EnvVar.JOB_RUN_UUID];
206+
207+
// Create a unique identifier for this run.
204208
const jobRunUuid = uuidV4();
205209
logger.info(`Job run UUID is ${jobRunUuid}.`);
206210
core.exportVariable(EnvVar.JOB_RUN_UUID, jobRunUuid);
@@ -229,6 +233,14 @@ async function run() {
229233
if (statusReportBase !== undefined) {
230234
await sendStatusReport(statusReportBase);
231235
}
236+
237+
// Throw a `ConfigurationError` if `previousJobRunUuid` is defined and not empty.
238+
if (previousJobRunUuid !== undefined && previousJobRunUuid.trim() !== "") {
239+
throw new ConfigurationError(
240+
`${EnvVar.JOB_RUN_UUID} was already set to '${previousJobRunUuid}'. The 'init' action should only be run once, and not in the same workflow as 'setup-codeql'.`,
241+
);
242+
}
243+
232244
const codeQLDefaultVersionInfo = await features.getDefaultCliVersion(
233245
gitHubVersion.type,
234246
);

0 commit comments

Comments
 (0)