stop git detatched head info

pull/289/head
Frostebite 2021-08-08 09:48:18 +01:00
parent 44966a7ba6
commit a35c029939
5 changed files with 67 additions and 4 deletions

View File

@ -53,6 +53,7 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-west-2
DEBUG: true
baseStackName: game-ci
with:
remoteBuildCluster: aws
projectPath: ${{ matrix.projectPath }}

View File

@ -7,6 +7,10 @@ Parameters:
Type: String
Default: development
Description: "Your deployment environment: DEV, QA , PROD"
Storage:
Type: String
Default: development
Description: "Your deployment environment: DEV, QA , PROD"
# ContainerPort:
# Type: Number
@ -250,7 +254,7 @@ Resources:
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Resource: '*'
DeleteCFNLambdaExecutionRole:
Type: "AWS::IAM::Role"
Properties:
@ -352,7 +356,7 @@ Resources:
Type: 'AWS::S3::Bucket'
DeletionPolicy: Retain
Properties:
BucketName: game-ci-storage
BucketName: !Ref Storage
@ -388,7 +392,7 @@ Outputs:
Value: !GetAtt 'ECSTaskExecutionRole.Arn'
Export:
Name: !Sub ${EnvironmentName}:ECSTaskExecutionRole
DeleteCFNLambdaExecutionRole:
Description: Lambda execution role for cleaning up cloud formations
Value: !GetAtt 'DeleteCFNLambdaExecutionRole.Arn'

29
dist/index.js vendored
View File

@ -925,6 +925,7 @@ class AWSBuildEnvironment {
commands[1] += `
echo "${logid}"
`;
yield this.setupBaseStack(CF);
const taskDefStackName = `${this.stackName}-${buildUid}`;
let taskDefCloudFormation = this.readTaskCloudFormationTemplate();
const cleanupTaskDefStackName = `${taskDefStackName}-cleanup`;
@ -1020,6 +1021,34 @@ class AWSBuildEnvironment {
};
});
}
setupBaseStack(CF) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
let createBaseStack = true;
const baseStackName = process.env.baseStackName || 'game-ci-base-stack-01';
const baseStack = fs.readFileSync(`${__dirname}/cloud-formations/base-setup.yml`, 'utf8');
for (const stack of ((_a = (yield CF.listStacks().promise())) === null || _a === void 0 ? void 0 : _a.StackSummaries) || []) {
if (stack.StackName === baseStackName) {
const updateInput = {
StackName: baseStackName,
TemplateBody: baseStack,
};
yield CF.updateStack(updateInput).promise();
createBaseStack = false;
}
}
if (createBaseStack) {
yield CF.createStack({
StackName: baseStackName,
TemplateBody: baseStack,
Parameters: [
{ ParameterKey: 'EnvironmentName', ParameterValue: 'development' },
{ ParameterKey: 'Storage', ParameterValue: `${baseStackName}-storage` },
],
});
}
});
}
handleStackCreationFailure(error, CF, taskDefStackName, taskDefCloudFormation, secrets) {
return __awaiter(this, void 0, void 0, function* () {
core.info(JSON.stringify(secrets, undefined, 4));

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -112,6 +112,7 @@ class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
commands[1] += `
echo "${logid}"
`;
await this.setupBaseStack(CF);
const taskDefStackName = `${this.stackName}-${buildUid}`;
let taskDefCloudFormation = this.readTaskCloudFormationTemplate();
const cleanupTaskDefStackName = `${taskDefStackName}-cleanup`;
@ -228,6 +229,34 @@ class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
};
}
async setupBaseStack(CF: SDK.CloudFormation) {
let createBaseStack: Boolean = true;
const baseStackName = process.env.baseStackName || 'game-ci-base-stack-01';
const baseStack = fs.readFileSync(`${__dirname}/cloud-formations/base-setup.yml`, 'utf8');
for (const stack of (await CF.listStacks().promise())?.StackSummaries || []) {
if (stack.StackName === baseStackName) {
const updateInput: SDK.CloudFormation.UpdateStackInput = {
StackName: baseStackName,
TemplateBody: baseStack,
};
await CF.updateStack(updateInput).promise();
createBaseStack = false;
}
}
if (createBaseStack) {
await CF.createStack({
StackName: baseStackName,
TemplateBody: baseStack,
Parameters: [
{ ParameterKey: 'EnvironmentName', ParameterValue: 'development' },
{ ParameterKey: 'Storage', ParameterValue: `${baseStackName}-storage` },
],
});
}
// wait for base stack to be finished...
}
async handleStackCreationFailure(
error: any,
CF: SDK.CloudFormation,