Skip to content

Commit

Permalink
Tag releases and have the server checkout the latest release
Browse files Browse the repository at this point in the history
Closes #36
  • Loading branch information
virajchitnis committed Jun 3, 2017
1 parent c3e6e4e commit 0a42b93
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion githook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
export PATH="/root/.nvm/versions/node/v6.10.1/bin:${PATH}"

git fetch origin
git checkout --force origin/master
git fetch --tags
latesttag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo Deploying ${latesttag}
git checkout --force ${latesttag}

yarn redeploy
./node_modules/forever/bin/forever restartall
4 changes: 2 additions & 2 deletions routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ router.get('/gitcommit', function (req, res){
const apikey = req.headers['api-key'];
if (apikey == configJSON.api_key) {
newDevice('_vcid', res, req, configJSON.mailgun_api_key, configJSON.authorized_device_secret);
exec('git rev-parse HEAD', function(err, stdout) {
const commitId = stdout.substring(0,7);
exec('git tag -l --points-at HEAD', function(err, stdout) {
const commitId = stdout;
res.status(200).send({
commit_id: commitId,
updated_at: configJSON.last_start_time
Expand Down
2 changes: 1 addition & 1 deletion routes/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ router.post('/githook', function (req, res) {
hmac.update(JSON.stringify(req.body));
computedHubSig = hmac.digest('hex');
if (xHubSig == computedHubSig) {
if (req.body.ref == "refs/heads/master") {
if (req.body.ref.startsWith("refs/tags/")) {
function puts(error, stdout, stderr) { sys.puts(stdout) }
exec("./githook.sh", puts);
res.send({
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class Footer extends React.Component {
let formattedDate = '';

if (commit_id != '') {
commitURL = "https://github.com/virajchitnis/virajchitnis.com/commit/" + commit_id;
commitURL = "https://github.com/virajchitnis/virajchitnis.com/tree/" + commit_id;
formattedDate = new Date(updated_at).toLocaleTimeString("en-us", options);
commitFooter = (
<p className="commit">
Expand Down

0 comments on commit 0a42b93

Please sign in to comment.