Skip to content

Commit

Permalink
Add support for current build command
Browse files Browse the repository at this point in the history
This lets us easily inspect what version Heimdall has deployed. The
number is a link to the Circle build, as well.
  • Loading branch information
Shadowfiend committed May 10, 2018
1 parent 17d595b commit 18d19a4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ jobs:
gcloud --quiet auth configure-docker
- run:
name: Build Docker Image
command: docker build -t gcr.io/cfc-production/heimdall:$CIRCLE_BUILD_NUM .
command: |
echo $CIRCLE_BUILD_NUM > BUILD
docker build -t gcr.io/cfc-production/heimdall:$CIRCLE_BUILD_NUM .
- run:
name: Push Docker Image
command: docker push gcr.io/${PROJECT_NAME}/heimdall:$CIRCLE_BUILD_NUM
Expand Down
Empty file added BUILD
Empty file.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN mkdir bin scripts
COPY external-scripts.json .
COPY bin ./bin
COPY scripts ./scripts
COPY BUILD ./BUILD

ENV PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH"

Expand Down
28 changes: 28 additions & 0 deletions scripts/current-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
let fs = require("fs")

// Description:
// Returns the current deployed build.
//
// Dependencies:
// None
//
// Commands:
// hubot current build
//
// Author:
// shadowfiend

let buildNumberBuffer = ""
try {
buildNumberBuffer = fs.readFileSync(`${__dirname}/../BUILD`)
} catch (e) {
console.error("Error reading buildNumber file: " + e)
}
let buildNumber = buildNumberBuffer.toString()

// TODO Announce new build to Bifrost flow, configured.

module.exports = function (robot) {
robot.respond(/current build/, (response) =>
response.send(`I'm on build [${buildNumber}](https://circle-ci.com/gh/cardforcoin/heimdall/${buildNumber})!`))
}

0 comments on commit 18d19a4

Please sign in to comment.