cleaner more readable ids and additional permission required for cleanup
parent
f67bc680b6
commit
f28b660597
|
|
@ -227,7 +227,7 @@ class AWS {
|
|||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const nanoid = nanoid_1.customAlphabet(alphabet, 9);
|
||||
const buildUid = `${process.env.GITHUB_RUN_NUMBER}-${nanoid()}`;
|
||||
const buildUid = `${nanoid()}-build-${process.env.GITHUB_RUN_NUMBER}-${buildParameters.platform}`;
|
||||
const branchName = (_a = process.env.GITHUB_REF) === null || _a === void 0 ? void 0 : _a.split('/').reverse()[0];
|
||||
core.info('Starting part 1/4 (clone from github and restore cache)');
|
||||
yield this.run(buildUid, buildParameters.awsStackName, 'alpine/git', ['/bin/sh'], [
|
||||
|
|
@ -262,10 +262,13 @@ class AWS {
|
|||
mkdir /data/${buildUid}/repo/${buildParameters.projectPath}/Library
|
||||
unzip -q "$latest" -d /data/${buildUid}/repo/${buildParameters.projectPath}/Library/.
|
||||
echo ' '
|
||||
echo 'Repo:'
|
||||
ls /data/${buildUid}/repo/
|
||||
echo ' '
|
||||
echo 'Project:'
|
||||
ls /data/${buildUid}/repo/${buildParameters.projectPath}
|
||||
echo ' '
|
||||
echo 'Library:'
|
||||
ls /data/${buildUid}/repo/${buildParameters.projectPath}/Library/
|
||||
echo ' '
|
||||
else
|
||||
|
|
@ -286,19 +289,17 @@ class AWS {
|
|||
ParameterKey: 'GithubToken',
|
||||
ParameterValue: buildParameters.githubToken,
|
||||
},
|
||||
], buildParameters.platform);
|
||||
]);
|
||||
core.info('Starting part 2/4 (build unity project)');
|
||||
yield this.run(buildUid, buildParameters.awsStackName, baseImage.toString(), ['/bin/sh'], [
|
||||
'-c',
|
||||
`
|
||||
cp -r /data/${buildUid}/builder/dist/default-build-script/ /UnityBuilderAction;
|
||||
cp -r /data/${buildUid}/builder/dist/entrypoint.sh /entrypoint.sh;
|
||||
cp -r /data/${buildUid}/builder/dist/steps/ /steps;
|
||||
ls;
|
||||
chmod -R +x /entrypoint.sh;
|
||||
chmod -R +x /steps;
|
||||
/entrypoint.sh;
|
||||
ls
|
||||
cp -r /data/${buildUid}/builder/dist/default-build-script/ /UnityBuilderAction;
|
||||
cp -r /data/${buildUid}/builder/dist/entrypoint.sh /entrypoint.sh;
|
||||
cp -r /data/${buildUid}/builder/dist/steps/ /steps;
|
||||
chmod -R +x /entrypoint.sh;
|
||||
chmod -R +x /steps;
|
||||
/entrypoint.sh;
|
||||
`,
|
||||
], '/data', `/data/${buildUid}/repo/`, [
|
||||
{
|
||||
|
|
@ -378,7 +379,7 @@ class AWS {
|
|||
ParameterKey: 'AndroidKeyAliasPass',
|
||||
ParameterValue: buildParameters.androidKeyaliasPass ? buildParameters.androidKeyaliasPass : '0',
|
||||
},
|
||||
], buildParameters.platform);
|
||||
]);
|
||||
core.info('Starting part 3/4 (zip unity build and Library for caching)');
|
||||
// Cleanup
|
||||
yield this.run(buildUid, buildParameters.awsStackName, 'alpine', ['/bin/sh'], [
|
||||
|
|
@ -402,7 +403,7 @@ class AWS {
|
|||
ParameterKey: 'GithubToken',
|
||||
ParameterValue: buildParameters.githubToken,
|
||||
},
|
||||
], buildParameters.platform);
|
||||
]);
|
||||
core.info('Starting part 4/4 (upload build to s3)');
|
||||
yield this.run(buildUid, buildParameters.awsStackName, 'amazon/aws-cli', ['/bin/sh'], [
|
||||
'-c',
|
||||
|
|
@ -433,7 +434,7 @@ class AWS {
|
|||
ParameterKey: 'AWSSecretAccessKey',
|
||||
ParameterValue: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
},
|
||||
], buildParameters.platform);
|
||||
]);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error);
|
||||
|
|
@ -441,18 +442,18 @@ class AWS {
|
|||
}
|
||||
});
|
||||
}
|
||||
static run(buildUid, stackName, image, entrypoint, commands, mountdir, workingdir, environment, secrets, platform) {
|
||||
static run(buildUid, stackName, image, entrypoint, commands, mountdir, workingdir, environment, secrets) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const ECS = new SDK.ECS();
|
||||
const CF = new SDK.CloudFormation();
|
||||
const taskDef = yield this.setupCloudFormations(CF, buildUid, stackName, image, entrypoint, commands, mountdir, workingdir, secrets, platform);
|
||||
const taskDef = yield this.setupCloudFormations(CF, buildUid, stackName, image, entrypoint, commands, mountdir, workingdir, secrets);
|
||||
yield this.runTask(taskDef, ECS, CF, environment, buildUid);
|
||||
yield this.cleanupResources(CF, taskDef);
|
||||
});
|
||||
}
|
||||
static setupCloudFormations(CF, buildUid, stackName, image, entrypoint, commands, mountdir, workingdir, secrets, platform) {
|
||||
static setupCloudFormations(CF, buildUid, stackName, image, entrypoint, commands, mountdir, workingdir, secrets) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const taskDefStackName = `${stackName}-${platform}-${buildUid}-build`;
|
||||
const taskDefStackName = `${stackName}-${buildUid}`;
|
||||
const taskDefCloudFormation = fs.readFileSync(`${__dirname}/task-def-formation.yml`, 'utf8');
|
||||
yield CF.createStack({
|
||||
StackName: taskDefStackName,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -9,7 +9,7 @@ class AWS {
|
|||
static async runBuildJob(buildParameters, baseImage) {
|
||||
try {
|
||||
const nanoid = customAlphabet(alphabet, 9);
|
||||
const buildUid = `${process.env.GITHUB_RUN_NUMBER}-${nanoid()}`;
|
||||
const buildUid = `${nanoid()}-build-${process.env.GITHUB_RUN_NUMBER}-${buildParameters.platform}`;
|
||||
const branchName = process.env.GITHUB_REF?.split('/').reverse()[0];
|
||||
|
||||
core.info('Starting part 1/4 (clone from github and restore cache)');
|
||||
|
|
@ -50,10 +50,13 @@ class AWS {
|
|||
mkdir /data/${buildUid}/repo/${buildParameters.projectPath}/Library
|
||||
unzip -q "$latest" -d /data/${buildUid}/repo/${buildParameters.projectPath}/Library/.
|
||||
echo ' '
|
||||
echo 'Repo:'
|
||||
ls /data/${buildUid}/repo/
|
||||
echo ' '
|
||||
echo 'Project:'
|
||||
ls /data/${buildUid}/repo/${buildParameters.projectPath}
|
||||
echo ' '
|
||||
echo 'Library:'
|
||||
ls /data/${buildUid}/repo/${buildParameters.projectPath}/Library/
|
||||
echo ' '
|
||||
else
|
||||
|
|
@ -79,7 +82,6 @@ class AWS {
|
|||
ParameterValue: buildParameters.githubToken,
|
||||
},
|
||||
],
|
||||
buildParameters.platform,
|
||||
);
|
||||
|
||||
core.info('Starting part 2/4 (build unity project)');
|
||||
|
|
@ -91,14 +93,12 @@ class AWS {
|
|||
[
|
||||
'-c',
|
||||
`
|
||||
cp -r /data/${buildUid}/builder/dist/default-build-script/ /UnityBuilderAction;
|
||||
cp -r /data/${buildUid}/builder/dist/entrypoint.sh /entrypoint.sh;
|
||||
cp -r /data/${buildUid}/builder/dist/steps/ /steps;
|
||||
ls;
|
||||
chmod -R +x /entrypoint.sh;
|
||||
chmod -R +x /steps;
|
||||
/entrypoint.sh;
|
||||
ls
|
||||
cp -r /data/${buildUid}/builder/dist/default-build-script/ /UnityBuilderAction;
|
||||
cp -r /data/${buildUid}/builder/dist/entrypoint.sh /entrypoint.sh;
|
||||
cp -r /data/${buildUid}/builder/dist/steps/ /steps;
|
||||
chmod -R +x /entrypoint.sh;
|
||||
chmod -R +x /steps;
|
||||
/entrypoint.sh;
|
||||
`,
|
||||
],
|
||||
'/data',
|
||||
|
|
@ -183,7 +183,6 @@ class AWS {
|
|||
ParameterValue: buildParameters.androidKeyaliasPass ? buildParameters.androidKeyaliasPass : '0',
|
||||
},
|
||||
],
|
||||
buildParameters.platform,
|
||||
);
|
||||
core.info('Starting part 3/4 (zip unity build and Library for caching)');
|
||||
// Cleanup
|
||||
|
|
@ -218,7 +217,6 @@ class AWS {
|
|||
ParameterValue: buildParameters.githubToken,
|
||||
},
|
||||
],
|
||||
buildParameters.platform,
|
||||
);
|
||||
|
||||
core.info('Starting part 4/4 (upload build to s3)');
|
||||
|
|
@ -261,7 +259,6 @@ class AWS {
|
|||
ParameterValue: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
},
|
||||
],
|
||||
buildParameters.platform,
|
||||
);
|
||||
} catch (error) {
|
||||
core.setFailed(error);
|
||||
|
|
@ -279,7 +276,6 @@ class AWS {
|
|||
workingdir,
|
||||
environment,
|
||||
secrets,
|
||||
platform,
|
||||
) {
|
||||
const ECS = new SDK.ECS();
|
||||
const CF = new SDK.CloudFormation();
|
||||
|
|
@ -294,7 +290,6 @@ class AWS {
|
|||
mountdir,
|
||||
workingdir,
|
||||
secrets,
|
||||
platform,
|
||||
);
|
||||
|
||||
await this.runTask(taskDef, ECS, CF, environment, buildUid);
|
||||
|
|
@ -312,9 +307,8 @@ class AWS {
|
|||
mountdir,
|
||||
workingdir,
|
||||
secrets,
|
||||
platform,
|
||||
) {
|
||||
const taskDefStackName = `${stackName}-${platform}-${buildUid}-build`;
|
||||
const taskDefStackName = `${stackName}-${buildUid}`;
|
||||
const taskDefCloudFormation = fs.readFileSync(`${__dirname}/task-def-formation.yml`, 'utf8');
|
||||
await CF.createStack({
|
||||
StackName: taskDefStackName,
|
||||
|
|
|
|||
Loading…
Reference in New Issue