Skip to content

Commit

Permalink
fix: Add build number to application artifact
Browse files Browse the repository at this point in the history
This is a requirement for using `GuEc2AppExperimental`.
  • Loading branch information
akash1810 committed Sep 19, 2024
1 parent ef093ab commit 9637877
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
cdk.out:
- cdk/cdk.out
prism:
- target/prism.deb
- dist
2 changes: 2 additions & 0 deletions cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ new Prism(app, 'Prism-CODE', {
minimumInstances: 1,
cloudFormationStackName: 'prism-CODE',
env: { region: 'eu-west-1' },
buildIdentifier: process.env.GITHUB_RUN_NUMBER ?? 'DEV',
});

new Prism(app, 'Prism-PROD', {
Expand All @@ -21,6 +22,7 @@ new Prism(app, 'Prism-PROD', {
minimumInstances: 2,
cloudFormationStackName: 'prism-PROD',
env: { region: 'eu-west-1' },
buildIdentifier: process.env.GITHUB_RUN_NUMBER ?? 'DEV',
});

new PrismAccess(app, 'PrismAccessStackSet');
Expand Down
1 change: 1 addition & 0 deletions cdk/lib/prism.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('The PrismEc2App stack', () => {
stage: 'PROD',
domainName: 'prism.gutools.co.uk',
minimumInstances: 2,
buildIdentifier: 'TEST',
});
expect(Template.fromStack(stack).toJSON()).toMatchSnapshot();
});
Expand Down
12 changes: 10 additions & 2 deletions cdk/lib/prism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import {
interface PrismProps extends Omit<GuStackProps, 'description' | 'stack'> {
domainName: string;
minimumInstances: number;

/**
* Which application build to run.
* This will typically match the build number provided by CI.
*/
buildIdentifier: string;
}

export class Prism extends GuStack {
Expand All @@ -37,6 +43,8 @@ export class Prism extends GuStack {
app,
});

const filename = `${app}-${props.buildIdentifier}.deb`;

const pattern = new GuEc2AppExperimental(this, {
applicationPort: 9000,
app,
Expand All @@ -47,8 +55,8 @@ export class Prism extends GuStack {
instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.MEDIUM),
userData: {
distributable: {
fileName: `${app}.deb`,
executionStatement: `dpkg -i /${app}/${app}.deb`,
fileName: filename,
executionStatement: `dpkg -i /${app}/${filename}`,
},
},
certificateProps: {
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ set -e

sbt clean scalafmtSbtCheck scalafmtCheckAll compile test debian:packageBin

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

0 comments on commit 9637877

Please sign in to comment.