Site updated: 2018-11-03 23:18:43
Showing
| ... | ... | @@ -19,7 +19,7 @@ |
| <meta property="og:description" content="In a previous post I talked about why I like the idea of a static site generator, and the reasons for choosing to use one. In this post I…"> | ||
| <meta property="og:locale" content="en"> | ||
| <meta property="og:image" content="http://blog.thebestjohn.com/images/gitlabrunner/runner.png"> | ||
| <meta property="og:updated_time" content="2018-11-03T18:11:22.621Z"> | ||
| <meta property="og:updated_time" content="2018-11-03T23:17:02.262Z"> | ||
| <meta name="twitter:card" content="summary"> | ||
| <meta name="twitter:title" content="Setting up Hexo Auto-deploy from Gitlab"> | ||
| <meta name="twitter:description" content="In a previous post I talked about why I like the idea of a static site generator, and the reasons for choosing to use one. In this post I…"> | ||
| ... | ... | @@ -74,8 +74,7 @@ |
| <h1 class="article__title" itemprop="headline">Setting up Hexo Auto-deploy from Gitlab</h1> | ||
| <div class="article__meta"><time class="article__meta__time" datetime="2018-04-30T21:40:00.000Z" itemprop="datePublished">April 30th 2018</time> | ||
| <div class="article__meta__categories"><a class="article__meta__categories__item" href="/categories/Web-Dev/">Web Dev</a><span class="article__meta__categories__separator">/</span><a class="article__meta__categories__item" href="/categories/Web-Dev/Gitlab/">Gitlab</a><span class="article__meta__categories__separator">/</span> | ||
| <a | ||
| class="article__meta__categories__item" href="/categories/Web-Dev/Gitlab/Automation/">Automation</a> | ||
| <a class="article__meta__categories__item" href="/categories/Web-Dev/Gitlab/Automation/">Automation</a> | ||
| </div> | ||
| </div> | ||
| <div class="article__contents"><img src="/images/gitlabrunner/runner.png"> | ||
| ... | ... | @@ -104,8 +103,7 @@ |
| <span data-prompt="Enter a passphrase(empty for no passphrase):" data-strings="" data-action="prompt" data-delay="3000">Enter a passphrase(empty for no passphrase):<br></span> | ||
| <span data-prompt="Enter same passphrase again:" data-strings="" data-action="prompt" data-delay="2000">Enter same passphrase again:<br></span> | ||
| <span data-strings="Your identification has been saved in /Users/john/testtt.<br>Your public key has been saved in /Users/john/testtt.pub.<br>The key fingerprint is:<br>SHA256:j+FL93E5e6btfzLZxkrWrZdrBkwqanJQtba1RZwROO8 runnerboi@gitlab<br/>The key's randomart image is:<br/>+---[RSA 2048]----+<br>| oo+ |<br>| . o + |<br>| . . + |<br>| . o . + |<br>| . S o B |<br>| . . * o E o.|<br>| . = + . B++|<br>| . = o . =+OO|<br>| + . . B%B|<br>+----[SHA256]-----+" | ||
| data-action="print" data-delay="0"> | ||
| <span data-strings="Your identification has been saved in /Users/john/testtt.<br>Your public key has been saved in /Users/john/testtt.pub.<br>The key fingerprint is:<br>SHA256:j+FL93E5e6btfzLZxkrWrZdrBkwqanJQtba1RZwROO8 runnerboi@gitlab<br/>The key's randomart image is:<br/>+---[RSA 2048]----+<br>| oo+ |<br>| . o + |<br>| . . + |<br>| . o . + |<br>| . S o B |<br>| . . * o E o.|<br>| . = + . B++|<br>| . = o . =+OO|<br>| + . . B%B|<br>+----[SHA256]-----+" data-action="print" data-delay="0"> | ||
| Your identification has been saved in /Users/john/testtt.<br> | ||
| Your public key has been saved in /Users/john/testtt.pub.<br> | ||
| The key fingerprint is:<br> | ||
| ... | ... | @@ -123,8 +121,7 @@ |
| | + . . B%B|<br fix="*"> | ||
| +----[SHA256]-----+<br></span> | ||
| <span data-strings="^3000cat ~/runnerboi.pub^600" data-action="type" data-delay="1000">$ cat ~/runnerboi.pub<br></span> | ||
| <span data-strings="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXnZZ0e0BKqH6i15DL+RO68paFABpXH+alHpAuyrhn3dtbPX0lOQJF275kt/qn8wwDRYAQvdWeTGynmj5d5ul1Fo+ONK+kPvAjX1WZowLEjsewWTHC1Qf0CtYphGoXoc1XRNPTu+wW3xPOCQQwz/gnqJeUw9bNpdj+qAo6JCkqnEb7eXWYfNWBckqgPx3R+hVDlrZxDGxoFOHQ06Wp3UkoWV5LUE1++0akjpIApU0pduX1wnBFCVH183oYuOeSftqYx7MBBGlsLO1+WNmOdaFSGqRLkrDT8e95NGdIGZuGovIRHwq+InnYOghOYQYRhgenaZw4u9Rf5hvVCMcvHHd1 runnerboi@gitlab" | ||
| data-action="print">ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXnZZ0e0BKqH6i15DL+RO68paFABpXH+alHpAuyrhn3dtbPX0lOQJF275kt/qn8wwDRYAQvdWeTGynmj5d5ul1Fo+ONK+kPvAjX1WZowLEjsewWTHC1Qf0CtYphGoXoc1XRNPTu+wW3xPOCQQwz/gnqJeUw9bNpdj+qAo6JCkqnEb7eXWYfNWBckqgPx3R+hVDlrZxDGxoFOHQ06Wp3UkoWV5LUE1++0akjpIApU0pduX1wnBFCVH183oYuOeSftqYx7MBBGlsLO1+WNmOdaFSGqRLkrDT8e95NGdIGZuGovIRHwq+InnYOghOYQYRhgenaZw4u9Rf5hvVCMcvHHd1 runnerboi@gitlab</span> | ||
| <span data-strings="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXnZZ0e0BKqH6i15DL+RO68paFABpXH+alHpAuyrhn3dtbPX0lOQJF275kt/qn8wwDRYAQvdWeTGynmj5d5ul1Fo+ONK+kPvAjX1WZowLEjsewWTHC1Qf0CtYphGoXoc1XRNPTu+wW3xPOCQQwz/gnqJeUw9bNpdj+qAo6JCkqnEb7eXWYfNWBckqgPx3R+hVDlrZxDGxoFOHQ06Wp3UkoWV5LUE1++0akjpIApU0pduX1wnBFCVH183oYuOeSftqYx7MBBGlsLO1+WNmOdaFSGqRLkrDT8e95NGdIGZuGovIRHwq+InnYOghOYQYRhgenaZw4u9Rf5hvVCMcvHHd1 runnerboi@gitlab" data-action="print">ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXnZZ0e0BKqH6i15DL+RO68paFABpXH+alHpAuyrhn3dtbPX0lOQJF275kt/qn8wwDRYAQvdWeTGynmj5d5ul1Fo+ONK+kPvAjX1WZowLEjsewWTHC1Qf0CtYphGoXoc1XRNPTu+wW3xPOCQQwz/gnqJeUw9bNpdj+qAo6JCkqnEb7eXWYfNWBckqgPx3R+hVDlrZxDGxoFOHQ06Wp3UkoWV5LUE1++0akjpIApU0pduX1wnBFCVH183oYuOeSftqYx7MBBGlsLO1+WNmOdaFSGqRLkrDT8e95NGdIGZuGovIRHwq+InnYOghOYQYRhgenaZw4u9Rf5hvVCMcvHHd1 runnerboi@gitlab</span> | ||
| <span data-action="empty"></span> | ||
| </div> | ||
| ... | ... | @@ -137,7 +134,7 @@ |
| <p>In the above example, we called it “runnerboi” and that generated us <code>runnerboi</code> and <code>runnerboi.pub</code>. <code>runnerboi</code> is your private key, which we’ll need later, and the <code>.pub</code> file is the public key. | ||
| Go ahead and cat that out, copy it to your clipboard and continue by adding our user.</p> | ||
| Go ahead and <code>cat</code> that out like the last part of the example, copy it to your clipboard and continue by adding our user.</p> | ||
| <p><img src="/images/gitlabrunner/newuser.png" alt="Add new user"></p> | ||
| <p>We add the user. It really doesn’t matter the username, email, name etc. We aren’t even going to verify this user. We’re never going to log in or set up a password. We’re just going to make it and use our admin superpowers to set it up.</p> | ||
| <p>If you don’t have admin powers on the gitlab instance, I’d imagine you could do this using a legitimate email and go that way but I have no idea how you’d go about setting up a CI on that or even if it’s feasible. So for now we’re going to | ||
| ... | ... | @@ -257,8 +254,7 @@ |
| the file that was generated along with <code>runnerboi.pub</code>, and move over to your <strong>blogsource</strong> repo’s CI/CD settings. Here we make a variable, name it <code>SSH_PRIVATE_KEY</code>, and paste the entire contents of that | ||
| file.</p> | ||
| <p><img src="/images/gitlabrunner/vars.png" alt="pipeline variables"></p> | ||
| <p>While we’re still on this page we want to add some ssh client config values. You can look more into setting up ssh configuration files in <a href="https://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/" rel="external nofollow noopener noreferrer" | ||
| target="_blank">this wonderful blog post</a>. For our purposes, we’ve set it up to ignore host key settings for every host, and set up our own gitlab server to use a specific port. If your server is visible to the internet, you’re definitely | ||
| <p>While we’re still on this page we want to add some ssh client config values. You can look more into setting up ssh configuration files in <a href="https://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/" rel="external nofollow noopener noreferrer" target="_blank">this wonderful blog post</a>. For our purposes, we’ve set it up to ignore host key settings for every host, and set up our own gitlab server to use a specific port. If your server is visible to the internet, you’re definitely | ||
| going to want to change the default port so, if you have, this is where you’d tell your runner about it.</p> | ||
| <p>This is what I put under the CI variable for <code>SSH_CONFIG</code>:<br><code>Host *\n\tStrictHostKeyChecking no\n\nHost gitlab.mysite.com\n\tport 2202</code><br><code>\n</code> is code for making a new line and <code>\t</code> is code for | ||
| pressing tab. This will parse out to:<br> | ||
| ... | ... | @@ -332,8 +328,7 @@ |
| <p>The “only” part of this will make it only run the “public” scripts when we commit to master.</p> | ||
| <h2 id="Using-it"><a href="#Using-it" class="headerlink" title="Using it."></a>Using it.</h2> | ||
| <p>Now we’re set up to run our build when we commit to blogsource. Commit these files and the CI should jump into action trying to build your site. Once it’s done, check your “blog” repo and you should have all your files nice and tidy. From | ||
| here you can do a git clone or git pull on your live server and your site will be updated. I’m working on making this part more automated for a future post but if you’re impatient you could try something like they did in <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps" | ||
| rel="external nofollow noopener noreferrer" target="_blank">this post on digital ocean</a>.</p> | ||
| here you can do a git clone or git pull on your live server and your site will be updated. I’m working on making this part more automated for a future post but if you’re impatient you could try something like they did in <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps" rel="external nofollow noopener noreferrer" target="_blank">this post on digital ocean</a>.</p> | ||
| <h2 id="Back-to-Gitlab-one-final-time-1"><a href="#Back-to-Gitlab-one-final-time-1" class="headerlink" title="Back to Gitlab one final time"></a>Back to Gitlab one final time</h2> | ||
| <p><img src="/images/gitlabrunner/vars.png" alt="pipeline variables"></p> | ||
| <p>Add to .known_hosts in order to not get “Host key verification failed…” error</p> | ||
| ... | ... | @@ -353,15 +348,11 @@ |
| </p> | ||
| <h2 id="Using-it-1"><a href="#Using-it-1" class="headerlink" title="Using it."></a>Using it.</h2> | ||
| <p>But really, I don’t want to have it build every commit… Sometimes I’m just editing drafts and literally nothing will change on the frontend. Well as of right now you need to add <code>[ci-skip]</code> to the commit message for that to happen. | ||
| Gitlab just recently started supporting push options. These allow you to pass options to your repo without fouling up your commit messages with a soup of tags and variables. There’s ongoing work in <a href="https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15643/commits" | ||
| rel="external nofollow noopener noreferrer" target="_blank">this merge request</a> to implement that with <code>git push -o ci-skip</code>. Pretty interesting!</p> | ||
| <p><a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/14499" rel="external nofollow noopener noreferrer" target="_blank">https://gitlab.com/gitlab-org/gitlab-ce/issues/14499</a><br><a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/18667" | ||
| rel="external nofollow noopener noreferrer" target="_blank">https://gitlab.com/gitlab-org/gitlab-ce/issues/18667</a></p> | ||
| Gitlab just recently started supporting push options. These allow you to pass options to your repo without fouling up your commit messages with a soup of tags and variables. There’s ongoing work in <a href="https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15643/commits" rel="external nofollow noopener noreferrer" target="_blank">this merge request</a> to implement that with <code>git push -o ci-skip</code>. Pretty interesting!</p> | ||
| <p><a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/14499" rel="external nofollow noopener noreferrer" target="_blank">https://gitlab.com/gitlab-org/gitlab-ce/issues/14499</a><br><a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/18667" rel="external nofollow noopener noreferrer" target="_blank">https://gitlab.com/gitlab-org/gitlab-ce/issues/18667</a></p> | ||
| <p>Really though, I don’t want to have it build every commit. Sometimes I’m just editing drafts and literally nothing will change on the frontend. Well as of right now you need to add <code>[ci-skip]</code> to the commit message for that to happen. | ||
| Gitlab just recently started supporting push options. These allow you to pass options to your repo without fouling up your commit messages with a soup of tags and variables. There’s ongoing work in <a href="https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15643/commits" | ||
| rel="external nofollow noopener noreferrer" target="_blank">this merge request</a> to implement that with <code>git push -o ci-skip</code>. Pretty interesting!</p> | ||
| <p><a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/14499" rel="external nofollow noopener noreferrer" target="_blank">https://gitlab.com/gitlab-org/gitlab-ce/issues/14499</a><br><a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/18667" | ||
| rel="external nofollow noopener noreferrer" target="_blank">https://gitlab.com/gitlab-org/gitlab-ce/issues/18667</a></p> | ||
| Gitlab just recently started supporting push options. These allow you to pass options to your repo without fouling up your commit messages with a soup of tags and variables. There’s ongoing work in <a href="https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15643/commits" rel="external nofollow noopener noreferrer" target="_blank">this merge request</a> to implement that with <code>git push -o ci-skip</code>. Pretty interesting!</p> | ||
| <p><a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/14499" rel="external nofollow noopener noreferrer" target="_blank">https://gitlab.com/gitlab-org/gitlab-ce/issues/14499</a><br><a href="https://gitlab.com/gitlab-org/gitlab-ce/issues/18667" rel="external nofollow noopener noreferrer" target="_blank">https://gitlab.com/gitlab-org/gitlab-ce/issues/18667</a></p> | ||
| <h2 id="That’s-all-folks"><a href="#That’s-all-folks" class="headerlink" title="That’s all folks!"></a>That’s all folks!</h2> | ||
| <p>As always, if you have any questions, just drop me a line and I’ll do my best to get you some answers. Have fun, keep making cool stuff and I’ll see you on the next project!</p> | ||
| <!-- useful links | ||
| ... | ... | @@ -374,23 +365,25 @@ https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html |
| --> | ||
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | ||
| <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
| <script src="/js/term.js"></script> | ||
| <script type="text/javascript"> | ||
| var terminals = [] | ||
| var terminals = []; | ||
| $(document).ready(function() { | ||
| $(".terminal-window").each(function(index) { | ||
| console.log(index, this); | ||
| (function() { | ||
| // your page initialization code here | ||
| // the DOM will be available here | ||
| var terms = document.getElementsByClassName("terminal-window"); | ||
| for (var i = 0; i < terms.length; i++) { | ||
| console.log(terms[i], this) | ||
| var ts = {} | ||
| ts.target = this | ||
| ts.target = terms[i] | ||
| ts.prompt = "$ " | ||
| ts.cursor = "▊" | ||
| var terminal = new Terminal(ts); | ||
| terminals.push(terminal); | ||
| }) | ||
| }); | ||
| } | ||
| })(); | ||
| </script> | ||
| </div> | ||
| <div class="article__author" itemscope="" itemprop="author" itemtype="https://schema.org/Person"><img class="article__author__image" src="/images/avatar.jpg" alt="John Warren"><a class="article__author__link" title="About John Warren" rel="author">John Warren</a> | ||
| ... | ... | @@ -401,8 +394,7 @@ https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html |
| <div class="sharer" id="sharer"> | ||
| <div class="sharer-inner"> | ||
| <div class="sharer__right"><button class="sharer__item" id="sharer-facebook"><i class="fa fa-facebook-official"></i></button><button class="sharer__item" id="sharer-twitter"><i class="fa fa-twitter"></i></button><button class="sharer__item" id="sharer-pinterest"><i class="fa fa-pinterest"></i></button> | ||
| <button | ||
| class="sharer__item" id="sharer-pocket"><i class="fa fa-get-pocket"></i></button> | ||
| <button class="sharer__item" id="sharer-pocket"><i class="fa fa-get-pocket"></i></button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ... | ... | @@ -418,7 +410,7 @@ https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html |
| })(); | ||
| </script><noscript>Enable JavaScript to see comments.</noscript> | ||
| <!-- Meta Tags for Structured Data--> | ||
| <meta itemprop="dateModified" content="2018-11-03T18:11:22.621Z"> | ||
| <meta itemprop="dateModified" content="2018-11-03T23:17:02.262Z"> | ||
| <meta itemprop="articleBody" content="In a previous post I talked about why I like the idea of a static site generator, and the reasons for choosing to use one. In this post I want to share how I got mine set up to | ||
| basically post..."> | ||
| <meta itemprop="url" content="/posts/setting-up-hexo-auto-deploy-from-gitlab/"> | ||
| ... | ... |
Please
register
or
sign in
to comment