{"id":215,"date":"2011-02-25T18:23:27","date_gmt":"2011-02-25T16:23:27","guid":{"rendered":"http:\/\/blog.railsware.com\/?p=215"},"modified":"2021-08-16T16:06:04","modified_gmt":"2021-08-16T13:06:04","slug":"how-to-crash-production-from-github-admin-page","status":"publish","type":"post","link":"https:\/\/railsware.com\/blog\/how-to-crash-production-from-github-admin-page\/","title":{"rendered":"How to crash production from github admin page"},"content":{"rendered":"\n<p>When I get into github project page yet another time and switched view from master branch to development I came up with idea that we should change the default branch to development as we work with it more.<\/p>\n\n\n\n<p>So, I navigate to admin tab and changed default branch with confidence that I did something useful.<\/p>\n\n\n\n<p>On the other part of the project people found a typo in one of our front page and decided to hot fix it in production. They change 1 symbol and made the deployment. Checked that production is alive and went home. No body did precise checks as change was so minor.<\/p>\n\n\n\n<p>After the midnight we discover that there are to many errors coming in the log. And the issue was that development branch was deployed to production.<\/p>\n\n\n\n<p>At first sight it was complete magic, but after some investigation we found out the following.<\/p>\n\n\n\n<p>By changing the github default branch, you don&#8217;t just change the default branch shown in the web interface. The HEAD ref is set to that branch.<br>Even that such behavior is non explicitly&nbsp;documented at&nbsp;<a title=\"Github default branch and clone\" href=\"http:\/\/help.github.com\/remotes\/#clone\" target=\"_blank\" rel=\"noopener\">help.github.com &#8211; clone function<\/a> and stated at&nbsp;<a title=\"Github pick your default branch\" href=\"https:\/\/github.com\/blog\/421-pick-your-default-branch\" target=\"_blank\" rel=\"noopener\">this blog post<\/a>.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>When no branch is set on capistrano deploy script &#8211; it will checkout HEAD, not master.<br>From Capistrano recipe for git:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> # When referencing \"head\", use the branch we want to deploy or, by # default, Git's reference of HEAD (the latest changeset in the default # branch, usually called \"master\"). def head variable(:branch) || 'HEAD' end <\/pre>\n\n\n\n<p>The only way how the github default branch could be implemented &#8211; was changing the HEAD ref.<br>The structural way how capistrano without an explicit branch set would work &#8211; is using a HEAD ref, as master is just a convention (best practice).<br>When you think about it that way &#8211; it all makes sense. One thing led to another.&nbsp;No Magic.<\/p>\n\n\n\n<p><strong>So lessons learned:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>never underestimate a delivery and do it only with a good QA coverage, even if it&#8217;s JUST 1 symbol patch;<\/li><li>use bookmarks to the what ever branch on the github page you like, and leave the default branch untouched;<\/li><li>when deciding to change it &#8211; make sure your deploy script is branch aware;<\/li><li>being used to git master branch and default patterns of using git &#8211; a good point is to re-read the documentation.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>When I get into github project page yet another time and switched view from master branch to development I came up with idea that we should change the default branch to development as we work with it more. So, I navigate to admin tab and changed default branch with confidence that I did something useful&#8230;.<\/p>\n","protected":false},"author":15,"featured_media":7475,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[3],"tags":[],"coauthors":["Bogdan Gusiev"],"class_list":["post-215","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development"],"acf":[],"aioseo_notices":[],"categories_data":[{"name":"Engineering","link":"https:\/\/railsware.com\/blog?category=development"}],"post_thumbnails":"https:\/\/railsware.com\/blog\/wp-content\/themes\/railsware\/vendors\/images\/article-thumbnail-default.jpg","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/comments?post=215"}],"version-history":[{"count":12,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/215\/revisions"}],"predecessor-version":[{"id":14171,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/215\/revisions\/14171"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/media\/7475"}],"wp:attachment":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/media?parent=215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/categories?post=215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/tags?post=215"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/coauthors?post=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}