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 17, 2024
1 parent 55ae138 commit de05bfc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
distribution: 'corretto'
cache: 'sbt'

- run: |
LAST_TEAMCITY_BUILD=1007
echo "BUILD_NUMBER=$(( $GITHUB_RUN_NUMBER + $LAST_TEAMCITY_BUILD ))" >> $GITHUB_ENV
# See https://github.com/github/scripts-to-rule-them-all
- name: Run script/ci
run: ./script/ci
Expand All @@ -50,11 +54,11 @@ jobs:
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
roleArn: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }}
buildNumberOffset: 1007
buildNumber: ${{ env.BUILD_NUMBER }}
projectName: tools::amiable
configPath: cdk/cdk.out/riff-raff.yaml
contentDirectories: |
cdk.out:
- cdk/cdk.out
amiable:
- amiable.deb
- dist
2 changes: 2 additions & 0 deletions cdk/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
jest.mock("@guardian/cdk/lib/constants/tracking-tag");

process.env.BUILD_NUMBER = "TEST";
4 changes: 2 additions & 2 deletions cdk/lib/amiable/__snapshots__/amiable.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ trap exitTrap EXIT
{
"Ref": "DistributionBucketName",
},
"/deploy/CODE/amiable/amiable.deb /amiable/
"/deploy/CODE/amiable/amiable-TEST.deb /amiable/amiable.deb
dpkg -i /amiable/amiable.deb
# GuEc2AppExperimental UserData Start
Expand Down Expand Up @@ -2619,7 +2619,7 @@ trap exitTrap EXIT
{
"Ref": "DistributionBucketName",
},
"/deploy/PROD/amiable/amiable.deb /amiable/
"/deploy/PROD/amiable/amiable-TEST.deb /amiable/amiable.deb
dpkg -i /amiable/amiable.deb
# GuEc2AppExperimental UserData Start
Expand Down
4 changes: 3 additions & 1 deletion cdk/lib/amiable/amiable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ export class Amiable extends GuStack {

const distBucket = GuDistributionBucketParameter.getInstance(this).valueAsString;

const buildNumber = process.env.BUILD_NUMBER ?? "DEV";

const userData = UserData.forLinux();
userData.addCommands(`
mkdir /amiable
aws --region eu-west-1 s3 cp s3://${distBucket}/${stack}/${stage}/${app}/conf/amiable-service-account-cert.json /amiable/
aws --region eu-west-1 s3 cp s3://${distBucket}/${stack}/${stage}/${app}/conf/amiable.conf /etc/
aws --region eu-west-1 s3 cp s3://${distBucket}/${stack}/${stage}/${app}/amiable.deb /amiable/
aws --region eu-west-1 s3 cp s3://${distBucket}/${stack}/${stage}/${app}/amiable-${buildNumber}.deb /amiable/amiable.deb
dpkg -i /amiable/amiable.deb`);

Expand Down
4 changes: 3 additions & 1 deletion script/ci
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ set -e


sbt clean scalafmtCheckAll compile test debian:packageBin
mv target/*.deb ./amiable.deb

mkdir -p dist
mv target/*.deb "dist/amiable-${BUILD_NUMBER}.deb"

0 comments on commit de05bfc

Please sign in to comment.