{"id":312362,"date":"2020-10-31T15:00:41","date_gmt":"2020-10-31T15:00:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=312362"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=312362","title":{"rendered":"\u042f \u0445\u0440\u0430\u043d\u044e \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d \u043a\u043b\u044e\u0447\u0438 \u043f\u0440\u044f\u043c\u043e \u0432 Git \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p><img decoding=\"async\" src=\"https:\/\/avatars.mds.yandex.net\/get-zen_doc\/244664\/pub_5c9b014f5e29d000b3872375_5c9b019bc568623051d58379\/scale_1200\" alt=\"image\"\/><\/p>\n<p>  <\/p>\n<p>\u0412\u0440\u0435\u043c\u044f \u0448\u043b\u043e, CI\/CD \u0442\u0443\u043b\u0437\u044b \u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0441\u0440\u0435\u0434 \u0438 \u043c\u0435\u0441\u0442 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 \u043c\u043d\u043e\u0436\u0438\u043b\u0438\u0441\u044c, \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0439\u0441\u0442\u0432\u0430 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043a\u043b\u044e\u0447 \u0433\u0434\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0443\u0441\u0442\u0430\u0440\u0435\u043b \u0432\u0441\u0435 \u043f\u043e\u0432\u044b\u0448\u0430\u043b\u043e\u0441\u044c. \u041d\u0443 \u0445\u0432\u0430\u0442\u0438\u0442 \u0443\u0436\u0435\u2026 \u041c\u043e\u0436\u043d\u043e \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043a\u043b\u044e\u0447\u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044e? \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0434\u0430, \u043c\u043e\u0436\u043d\u043e. \u0418 \u044d\u0442\u043e \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0447\u0442\u043e \u044f \u0434\u0435\u043b\u0430\u043b \u0440\u0430\u043d\u044c\u0448\u0435.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0434\u0443\u0448\u0435\u0440\u0430\u0437\u0434\u0438\u0440\u0430\u044e\u0449\u0443\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u043e \u0442\u043e\u043c, \u0441 \u043a\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438 \u0432\u0441\u0435 \u043c\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u044f\u043a\u0438\u0445 \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u043a \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043a \u0434\u0435\u043b\u0443.<\/p>\n<p>  <\/p>\n<h2 id=\"celi\">\u0426\u0435\u043b\u0438<\/h2>\n<p>  <\/p>\n<ul>\n<li>\u041d\u0435 \u0445\u043e\u0447\u0443 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c\u0441\u044f \u043e \u0442\u043e\u043c, \u0432\u0441\u0435 \u043b\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u043a\u043e\u0434\u0430 \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\/\u0441\u0442\u0435\u0439\u0434\u0436\u0438\u043d\u0433<\/li>\n<li>\u041d\u0435 \u0445\u043e\u0447\u0443 \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0434\u0430\u0442\u044c \u043d\u043e\u0432\u043e\u043c\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443, \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0432\u0448\u0435\u043c\u0443\u0441\u044f \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443<\/li>\n<li>\u0425\u043e\u0447\u0443 \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 CI \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0438\u0441\u044c \u0431\u0435\u0437 \u0442\u0430\u043d\u0446\u0435\u0432 \u0441 \u0431\u0443\u0431\u043d\u043e\u043c, \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u0430\u043a \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435<\/li>\n<li>\u0425\u043e\u0447\u0443 \u0447\u0442\u043e\u0431\u044b \u043a\u043b\u044e\u0447\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a\u043e\u0434\u0430.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"reshenie\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0432\u0430 \u0431\u0430\u0448 \u0441\u043a\u0440\u0438\u043f\u0442\u0430: <code>encrypt.sh<\/code> \u0438 <code>decrypt.sh<\/code>.<\/p>\n<p>  <\/p>\n<p><code>encrypt.sh<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">#!\/bin\/bash  # sh encrypt.sh &lt;.\/path\/to\/file.js&gt; &lt;environment&gt; &lt;password&gt;  LOCAL_IP_REMOVED='Y'  if [[ $2 == 'local' ]]; then   read -p &quot;You are encrypting local environment. \\   Did you remove your local ip address from configs? Y\/n&quot; LOCAL_IP_REMOVED fi  if [[ $LOCAL_IP_REMOVED != 'Y' ]]; then   echo &quot;Well, go on and remove it then! Aborting encryiption&quot;   exit 1 fi  echo &quot;encrypting $1&quot; openssl enc -aes-128-cbc -a -salt -pass pass:$3 -in $1 -out $1.${2}-enc -md md5 echo &quot;done&quot;<\/code><\/pre>\n<p>  <\/p>\n<p><code>decrypt.sh<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">#!\/bin\/bash # sh decrypt.sh &lt;environment&gt; &lt;password&gt;  echo &quot;decrypting $1 environment&quot;  for file in $(find . -not -path &quot;*\/node_modules\/*&quot; -name &quot;*.$1-enc&quot;) do     echo &quot;decrypting $file to ${file\/\/.$1-enc}&quot;     openssl enc -aes-128-cbc -a -d -salt -pass pass:$2 -in $file -out &quot;${file\/\/.$1-enc}&quot; -md md5 done  if [[ $1 == 'local' ]]; then   LOCAL_IP=`ifconfig | sed -En 's\/127.0.0.1\/\/;s\/.*inet (addr:)?(([0-9]*\\.){3}[0-9]*).*\/\\2\/p'`   echo &quot;Also replacing localhost with your local machine ip: $LOCAL_IP&quot;   # optionally, add logic to replace &quot;localhost&quot; with your machine IP   sed -i ''  &quot;s|localhost|$LOCAL_IP|g&quot; '.\/src\/env.js' fi<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0441\u0435\u043a\u0440\u0435\u0442\u043a\u0438 \u0432 \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u0430\u043a \u0443\u0434\u043e\u0431\u043d\u043e. \u0411\u0443\u0434\u044c \u0442\u043e <code>.env<\/code>, <code>env.js<\/code> \u0438\u043b\u0438 \u0447\u0442\u043e \u0442\u0430\u043c \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0432 <code>.gitignore<\/code>.<\/p>\n<p>  <\/p>\n<p>\u042e\u0437\u0430\u0435\u043c <code>encrypt.sh<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">sh encrypt.sh .\/src\/env.js &lt;environment&gt; &lt;very_secure_password&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0448\u0438\u0444\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043a\u043e\u043f\u0438\u044f. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 <code>.\/src\/env.js.production-enc<\/code>.<br \/>  \u0418<\/p>\n<p>  <\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u0431\u043e\u0440\u0430 \u043f\u0430\u0440\u043e\u043b\u044f \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u043a\u043d\u0443\u0442\u044c <a href=\"https:\/\/howsecureismypassword.net\/\" rel=\"nofollow\">\u0442\u0443\u0442<\/a>:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/o3\/4s\/b-\/o34sb-5yv09rywkczbxlnlu0afc.png\"\/><\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0432\u0435\u0442\u0443\u044e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u0442\u0440\u0435\u0445 <code>environment<\/code>\u043e\u0432: <code>local<\/code>, <code>staging<\/code>, <code>production<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c <code>local<\/code> \u0441\u0440\u0435\u0434\u044b \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 <code>decrypt.sh<\/code> \u043c\u043e\u0436\u0435\u0442 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0442\u044c <code>localhost<\/code> \u0432 \u0432\u0430\u0448\u0438\u0445 \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u0445 \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 IP \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430. \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u043c\u0430\u0440\u0442\u0444\u043e\u043d \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u0438\u043b\u0441\u044f \u043a \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443.<\/p>\n<p>  <\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/525928\/\"> https:\/\/habr.com\/ru\/post\/525928\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p><img decoding=\"async\" src=\"https:\/\/avatars.mds.yandex.net\/get-zen_doc\/244664\/pub_5c9b014f5e29d000b3872375_5c9b019bc568623051d58379\/scale_1200\" alt=\"image\"\/><\/p>\n<p>  <\/p>\n<p>\u0412\u0440\u0435\u043c\u044f \u0448\u043b\u043e, CI\/CD \u0442\u0443\u043b\u0437\u044b \u043c\u0435\u043d\u044f\u043b\u0438\u0441\u044c, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432, \u0441\u0440\u0435\u0434 \u0438 \u043c\u0435\u0441\u0442 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 \u043c\u043d\u043e\u0436\u0438\u043b\u0438\u0441\u044c, \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0439\u0441\u0442\u0432\u0430 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043a\u043b\u044e\u0447 \u0433\u0434\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0443\u0441\u0442\u0430\u0440\u0435\u043b \u0432\u0441\u0435 \u043f\u043e\u0432\u044b\u0448\u0430\u043b\u043e\u0441\u044c. \u041d\u0443 \u0445\u0432\u0430\u0442\u0438\u0442 \u0443\u0436\u0435\u2026 \u041c\u043e\u0436\u043d\u043e \u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043a\u043b\u044e\u0447\u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044e? \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0434\u0430, \u043c\u043e\u0436\u043d\u043e. \u0418 \u044d\u0442\u043e \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0447\u0442\u043e \u044f \u0434\u0435\u043b\u0430\u043b \u0440\u0430\u043d\u044c\u0448\u0435.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-312362","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/312362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=312362"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/312362\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}