Skip to content

Commit

Permalink
Add exit code as an output. Warning annotation on license activation …
Browse files Browse the repository at this point in the history
…retry
  • Loading branch information
AndrewKahr committed Nov 25, 2023
1 parent 58338a2 commit 479005d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 31 deletions.
29 changes: 16 additions & 13 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions dist/platforms/ubuntu/steps/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ if [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then
echo "Activation successful"
break
else
echo "Activation failed, retrying in $delay seconds..."
sleep $delay

# Increment retry count
((retry_count++))

echo "::warning ::Activation failed, attempting retry #$retry_count"
echo "Activation failed, retrying in $delay seconds..."
sleep $delay

# Double the delay for the next iteration
delay=$((delay * 2))
fi
Expand Down
20 changes: 11 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,27 @@ async function runMain() {
const buildParameters = await BuildParameters.create();
const baseImage = new ImageTag(buildParameters);

let exitCode = 0;

if (buildParameters.providerStrategy === 'local') {
core.info('Building locally');
await PlatformSetup.setup(buildParameters, actionFolder);
if (process.platform === 'darwin') {
MacBuilder.run(actionFolder);
} else {
await Docker.run(baseImage.toString(), {
workspace,
actionFolder,
...buildParameters,
});
}
exitCode =
process.platform === 'darwin'
? await MacBuilder.run(actionFolder)
: await Docker.run(baseImage.toString(), {
workspace,
actionFolder,
...buildParameters,
});
} else {
await CloudRunner.run(buildParameters, baseImage.toString());
}

// Set output
await Output.setBuildVersion(buildParameters.buildVersion);
await Output.setAndroidVersionCode(buildParameters.androidVersionCode);
await Output.setExitCode(exitCode);
} catch (error) {
core.setFailed((error as Error).message);
}
Expand Down
7 changes: 4 additions & 3 deletions src/model/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Docker {
options: ExecOptions | undefined = undefined,
entrypointBash: boolean = false,
errorWhenMissingUnityBuildResults: boolean = false,
) {
): Promise<number> {
let runCommand = '';
switch (process.platform) {
case 'linux':
Expand All @@ -27,9 +27,10 @@ class Docker {
}
if (options) {
options.silent = silent;
await execWithErrorCheck(runCommand, undefined, options, errorWhenMissingUnityBuildResults);

return await execWithErrorCheck(runCommand, undefined, options, errorWhenMissingUnityBuildResults);
} else {
await execWithErrorCheck(runCommand, undefined, { silent }, errorWhenMissingUnityBuildResults);
return await execWithErrorCheck(runCommand, undefined, { silent }, errorWhenMissingUnityBuildResults);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/model/mac-builder.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { execWithErrorCheck } from './exec-with-error-check';

class MacBuilder {
public static async run(actionFolder: string, silent: boolean = false) {
await execWithErrorCheck('bash', [`${actionFolder}/platforms/mac/entrypoint.sh`], {
public static async run(actionFolder: string, silent: boolean = false): Promise<number> {
return await execWithErrorCheck('bash', [`${actionFolder}/platforms/mac/entrypoint.sh`], {
silent,
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/model/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class Output {
static async setAndroidVersionCode(androidVersionCode: string) {
core.setOutput('androidVersionCode', androidVersionCode);
}

static async setExitCode(exitCode: number) {
core.setOutput('exitCode', exitCode);
}
}

export default Output;

0 comments on commit 479005d

Please sign in to comment.