Skip to content

Commit b4d471a

Browse files
authored
GITHUB_* enironement variables are available during script execution (#10)
1 parent a137ed9 commit b4d471a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ const run = async () => {
3535
inlineScript = ` set -e >&2; echo '${START_SCRIPT_EXECUTION_MARKER}' >&2; ${inlineScript}`;
3636
scriptFileName = await createScriptFile(inlineScript);
3737
let startCommand: string = ` ${BASH_ARG}${CONTAINER_TEMP_DIRECTORY}/${scriptFileName} `;
38-
38+
let gitHubEnvironmentVariables = '';
39+
for (let key in process.env){
40+
if (key.toUpperCase().startsWith("GITHUB_") && key.toUpperCase() !== 'GITHUB_WORKSPACE' && process.env[key]){
41+
gitHubEnvironmentVariables += ` -e ${key}=${process.env[key]} `;
42+
}
43+
}
3944
/*
4045
For the docker run command, we are doing the following
4146
- Set the working directory for docker continer
@@ -45,7 +50,8 @@ const run = async () => {
4550
*/
4651
let command: string = `run --workdir ${CONTAINER_WORKSPACE} -v ${process.env.GITHUB_WORKSPACE}:${CONTAINER_WORKSPACE} `;
4752
command += ` -v ${process.env.HOME}/.azure:/root/.azure -v ${TEMP_DIRECTORY}:${CONTAINER_TEMP_DIRECTORY} `;
48-
command += `-e GITHUB_WORKSPACE=${CONTAINER_WORKSPACE} -e GITHUB_SHA=${process.env.GITHUB_SHA} `;
53+
command += ` ${gitHubEnvironmentVariables} `;
54+
command += `-e GITHUB_WORKSPACE=${CONTAINER_WORKSPACE} `;
4955
command += `--name ${CONTAINER_NAME} `;
5056
command += ` mcr.microsoft.com/azure-cli:${azcliversion} ${startCommand}`;
5157
console.log(`${START_SCRIPT_EXECUTION_MARKER}${azcliversion}`);

0 commit comments

Comments
 (0)