diff --git a/bin/action.min.js b/bin/action.min.js index 8324beb..c77f9a9 100644 --- a/bin/action.min.js +++ b/bin/action.min.js @@ -92976,7 +92976,6 @@ async function execWithCredentials(args, projectId, gacFilename, opts) { } return deployOutputBuf.length ? deployOutputBuf[deployOutputBuf.length - 1].toString("utf-8") : ""; // output from the CLI } - async function deployPreview(gacFilename, deployConfig) { const { projectId, @@ -93026,6 +93025,8 @@ function getChannelId(configuredChannelId, ghContext) { } else if (ghContext.payload.pull_request) { const branchName = ghContext.payload.pull_request.head.ref.substr(0, 20); tmpChannelId = `pr${ghContext.payload.pull_request.number}-${branchName}`; + } else { + throw Error(`ChannelId is empty. No branch was found in the current context. Please provide a channelId for test environments.`); } // Channel IDs can only include letters, numbers, underscores, hyphens, and periods. const invalidCharactersRegex = /[^a-zA-Z0-9_\-\.]/g; diff --git a/src/getChannelId.ts b/src/getChannelId.ts index 09629ab..b66f108 100644 --- a/src/getChannelId.ts +++ b/src/getChannelId.ts @@ -24,11 +24,16 @@ export function getChannelId(configuredChannelId: string, ghContext: Context) { } else if (ghContext.payload.pull_request) { const branchName = ghContext.payload.pull_request.head.ref.substr(0, 20); tmpChannelId = `pr${ghContext.payload.pull_request.number}-${branchName}`; + } else { + throw Error( + `ChannelId is empty. No branch was found in the current context. Please provide a channelId for test environments.` + ); } // Channel IDs can only include letters, numbers, underscores, hyphens, and periods. const invalidCharactersRegex = /[^a-zA-Z0-9_\-\.]/g; const correctedChannelId = tmpChannelId.replace(invalidCharactersRegex, "_"); + if (correctedChannelId !== tmpChannelId) { console.log( `ChannelId "${tmpChannelId}" contains unsupported characters. Using "${correctedChannelId}" instead.`