Skip to content

Commit

Permalink
Add build number to user data
Browse files Browse the repository at this point in the history
  • Loading branch information
akash1810 committed Jul 15, 2024
1 parent f15ba12 commit 7cefce3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ jobs:
cdk.out:
- cdk/cdk.out
cdk-playground:
- target/cdk-playground.deb
- dist/cdk-playground
cdk-playground-lambda:
- lambda/cdk-playground-lambda.zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target
logs
lambda/cdk-playground-lambda.zip
dist/
3 changes: 2 additions & 1 deletion cdk/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
jest.mock("@guardian/cdk/lib/constants/tracking-tag");
jest.mock('@guardian/cdk/lib/constants/tracking-tag');
process.env.GITHUB_RUN_NUMBER = 'TEST';
12 changes: 7 additions & 5 deletions cdk/lib/cdk-playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import type {
CfnUpdatePolicy,
} from 'aws-cdk-lib';
import { Duration, Tags } from 'aws-cdk-lib';
import { CfnAutoScalingGroup, UpdatePolicy } from 'aws-cdk-lib/aws-autoscaling';
import type { CfnAutoScalingGroup } from 'aws-cdk-lib/aws-autoscaling';
import { AutoScalingGroup, UpdatePolicy } from 'aws-cdk-lib/aws-autoscaling';

Check warning on line 16 in cdk/lib/cdk-playground.ts

View workflow job for this annotation

GitHub Actions / CI

'AutoScalingGroup' is defined but never used
import { InstanceClass, InstanceSize, InstanceType } from 'aws-cdk-lib/aws-ec2';
import { Runtime } from 'aws-cdk-lib/aws-lambda';
import { AutoScalingGroup } from 'aws-cdk-lib/aws-autoscaling';

export class CdkPlayground extends GuStack {
constructor(
Expand All @@ -36,14 +36,16 @@ export class CdkPlayground extends GuStack {
const ec2App = 'cdk-playground';
const ec2AppDomainName = 'cdk-playground.gutools.co.uk';

const buildNumber = process.env.GITHUB_RUN_NUMBER ?? 'DEV';

const { loadBalancer, autoScalingGroup } = new GuPlayApp(this, {
app: ec2App,
instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.MICRO),
access: { scope: AccessScope.PUBLIC },
userData: {
distributable: {
fileName: `${ec2App}.deb`,
executionStatement: `dpkg -i /${ec2App}/${ec2App}.deb`,
fileName: `${ec2App}-${buildNumber}.deb`,
executionStatement: `dpkg -i /${ec2App}/${ec2App}-${buildNumber}.deb`,
},
},
certificateProps: {
Expand All @@ -67,7 +69,7 @@ export class CdkPlayground extends GuStack {
willReplace: true,
} as CfnAutoScalingReplacingUpdate,
};
let asg = autoScalingGroup.node.defaultChild as CfnAutoScalingGroup;
const asg = autoScalingGroup.node.defaultChild as CfnAutoScalingGroup;
// asg.desiredCapacity = '3';
asg.cfnOptions.updatePolicy = updatePolicy;

Expand Down
4 changes: 2 additions & 2 deletions script/ci
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ set -e

sbt clean compile test debian:packageBin

# `sbt debian:packageBin` produces `target/cdk-playground_1.0-SNAPSHOT_all.deb`. Rename it to something easier.
mv target/cdk-playground_1.0-SNAPSHOT_all.deb target/cdk-playground.deb
mkdir -p dist/cdk-playground
mv target/cdk-playground_1.0-SNAPSHOT_all.deb "dist/cdk-playground/cdk-playground-$GITHUB_RUN_NUMBER.deb"

0 comments on commit 7cefce3

Please sign in to comment.