diff --git a/Dockerfile b/Dockerfile index 7d4dcb7..5ce6670 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,8 @@ RUN curl https://api.rollbar.com/api/1/deploy/ \ -F revision=$(git log -n 1 --pretty=format:"%H") \ -F local_username="$(git log -n 1 --pretty=format:"%an")" +RUN node setup.js + WORKDIR /usr/src/app/build CMD [ "node", "server.js" ] diff --git a/setup.js b/setup.js new file mode 100644 index 0000000..c3cecb9 --- /dev/null +++ b/setup.js @@ -0,0 +1,24 @@ +/* eslint-disable no-console */ +const exec = require('child_process').exec; +const fs = require('fs'); + +const config = { + build: {}, +}; + +function writeConfigFile() { + fs.writeFile('build/public/config.json', JSON.stringify(config), (err) => { + if (err) { + return console.error(err); + } + return console.log('Config file saved'); + }); +} + +exec('git log -n 1 --pretty=format:"%H"', (err, stdout) => { + if (stdout) { + config.build.hash = stdout; + config.build.time = new Date(); + writeConfigFile(); + } +}); diff --git a/src/routes/admin/Admin.js b/src/routes/admin/Admin.js index 501c386..09e2e4a 100644 --- a/src/routes/admin/Admin.js +++ b/src/routes/admin/Admin.js @@ -22,6 +22,10 @@ class Admin extends React.Component { name: PropTypes.string, total: PropTypes.integer, })).isRequired, + build: PropTypes.shape({ + hash: PropTypes.string, + time: PropTypes.string, + }), }; render() { @@ -50,6 +54,12 @@ class Admin extends React.Component { ))} +