Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add sha to git commit or elastic beanstalk deploy

I'm deploying an application with elastic beanstalk, which has its own deploy tool. This tool takes the latest commit, creates a zip from it, and deploys that to the cloud. To verify the deploy on each server, I'd like it to be able to report its own SHA once it has been deployed. There are actually a few valid approaches:

  • Add SHA to current commit, with a git hook.
  • Alter the EB deploy scripts to include a specific uncommitted file, which can be easily created in a deploy script or git hook.
  • Make elastic beanstalk current application version label available to the instance.
like image 602
Peter Ehrlich Avatar asked Sep 02 '25 05:09

Peter Ehrlich


1 Answers

I solved this with .gitattribtues export-subst. (http://git-scm.com/docs/gitattributes) This automatically adds the SHA to the repo when it is archived, which is what elastic-beanstalk does upon deploy.

My .gitattributes:

*.py diff=python
version.txt export-subst

My version.txt:

$Format:%H$

See https://stackoverflow.com/a/16365314/478354

like image 75
Peter Ehrlich Avatar answered Sep 04 '25 19:09

Peter Ehrlich