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 18, 2024
1 parent 13fce05 commit 664d5c5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/ci-sbt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,27 @@ jobs:
cache: 'npm'
cache-dependency-path: 'cdk/package-lock.json'

# This step creates an environment variable `BUILD_NUMBER`.
# It is used by:
# - The `script/ci` script
# - The CDK infrastructure
# - The `guardian/actions-riff-raff` GitHub Action
- run: |
LAST_TEAMCITY_BUILD=1265
echo "BUILD_NUMBER=$(( $GITHUB_RUN_NUMBER + $LAST_TEAMCITY_BUILD ))" >> $GITHUB_ENV
- name: Run script/ci
run: ./script/ci

- uses: guardian/actions-riff-raff@a8a8cabedb56d2d8922017efedba7fd09e5e6980 # v4.0.6
with:
projectName: security-hq
roleArn: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }}
# Seed the build number with last number from TeamCity.
buildNumberOffset: 1265
buildNumber: ${{ env.BUILD_NUMBER }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
configPath: hq/conf/riff-raff.yaml
contentDirectories: |
security-hq-cfn:
- cdk/cdk.out/security-hq.template.json
security-hq:
- hq/target/security-hq.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";
2 changes: 1 addition & 1 deletion cdk/lib/__snapshots__/security-hq.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ trap exitTrap EXIT
{
"Ref": "DistributionBucketName",
},
"/security/PROD/security-hq/security-hq.deb /tmp/installer.deb
"/security/PROD/security-hq/security-hq-TEST.deb /tmp/installer.deb
dpkg -i /tmp/installer.deb
# GuEc2AppExperimental UserData Start
Expand Down
4 changes: 3 additions & 1 deletion cdk/lib/security-hq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ export class SecurityHQ extends GuStack {

const domainName = "security-hq.gutools.co.uk";

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

const userData = UserData.forLinux();
userData.addCommands(`# setup security-hq
mkdir -p /etc/gu
aws --region eu-west-1 s3 cp s3://${distBucket.valueAsString}/security/${this.stage}/security-hq/security-hq.conf /etc/gu
aws --region eu-west-1 s3 cp s3://${distBucket.valueAsString}/security/${this.stage}/security-hq/security-hq-service-account-cert.json /etc/gu
aws --region eu-west-1 s3 cp s3://${distBucket.valueAsString}/security/${this.stage}/security-hq/security-hq.deb /tmp/installer.deb
aws --region eu-west-1 s3 cp s3://${distBucket.valueAsString}/security/${this.stage}/security-hq/security-hq-${buildNumber}.deb /tmp/installer.deb
dpkg -i /tmp/installer.deb`);

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

./sbt --no-conf '; project hq; clean; compile; test; Debian / packageBin'

# `sbt Debian / packageBin` produces `hq/target/security-hq_x.x.x_all.deb`. Rename it to something easier.
# TODO Work out how to do this within build.sbt
mv hq/target/security-hq_*_all.deb hq/target/security-hq.deb
mkdir -p dist
mv hq/target/security-hq_*_all.deb "dist/security-hq-$BUILD_NUMBER.deb"

0 comments on commit 664d5c5

Please sign in to comment.