Skip to content

Add current Git commit hash to view #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 23, 2015
Merged

Add current Git commit hash to view #125

merged 5 commits into from
Oct 23, 2015

Conversation

robwise
Copy link
Contributor

@robwise robwise commented Oct 21, 2015

No description provided.

@@ -1,4 +1,9 @@
<h2>Using React + Redux + Rails Backend (using the react_on_rails gem)</h2>
<p>current Git commit:
<span id="current-git-commit-sha">
<%= @git_commit_sha %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this clickable to go to the commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justin808 Good idea! I think I will also change it to use the shorter version.

- refactor GitCommitSha class according to suggestions by @justin808
- access GitCommitSha directly from pages_helper instead of going through controller
- display shorter version of the hash
- make the hash link to the corresponding commit on GitHub

# Run migrations always just in case
heroku run rake db:migrate --remote $app
heroku restart --remote $app
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dylangrafmyre Could you please help with implementing this deploy script somehow?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robwise @justin808 I really don't think we should be using this. Better just better to setup CI to deploy after build passes. Need to eliminate as may manual steps as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dylangrafmyre Is there a way to somehow set the DEPLOYMENT_SHA environment variable on Heroku to the latest commit on deployment automatically? That's all we're really trying to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dylangrafmyre @justin808 What about instead of the scripts/deploy approach, we capture the SOURCE_VERSION environment variable (doc) on Heroku? Justin, from the thread I found where you were looking into this before, it sounds like the variable is only available during the compilation phase of building the app.

Therefore, our code to grab it would need to go in some sort of buildpack. Modifying the buildpack is probably a bad idea, but we can add our own custom buildpack that does ONLY this special thing. Heroku is apparently capable of running multiple buildpacks sequentially for the same build.

Actually, it looks like we are already running multiple buildpacks because of the need for both node and ruby. And this guy's project seems to be doing exactly what I was saying above: https://github.com/sreid/heroku-buildpack-sourceversion

I can make the necessary changes very easily if this is the route we want to go.

Heroku does not provide access to Git via the command line, so the methods that work for the dev and test environments won't work here. Instead, we can utilize an additional buildpack in .buildpacks to write the SOURCE_VERSION environment variable to a file named .source_version in the application root. We cannot reference this environment variable directly from the app because Heroku only makes it available during the compilation phase of the build, hence the need to use a buildpack to write it to a file for later use by the app.
@robwise robwise changed the title [WIP]: Add current Git commit hash to view Add current Git commit hash to view Oct 23, 2015
@robwise
Copy link
Contributor Author

robwise commented Oct 23, 2015

Ready for review!

justin808 added a commit that referenced this pull request Oct 23, 2015
Add current Git commit hash to view
@justin808 justin808 merged commit ff67292 into shakacode:master Oct 23, 2015
@justin808
Copy link
Member

LGTM! Great job!! Love the clean code and clean tests!

@justin808
Copy link
Member

Very nice!

2015-10-23_14-04-14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants