From eddbf2c36ea9f0b23f67f9b495dfb91abdc6bb53 Mon Sep 17 00:00:00 2001 From: Asocia Date: Wed, 5 Jan 2022 05:21:24 +0000 Subject: [PATCH] jekyll build from Action 38fd8a9946595cc5292268d424b283f3ba24a8f4 --- 2022/01/04/build-and-deploy-automatically.html | 5 +++-- feed.xml | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/2022/01/04/build-and-deploy-automatically.html b/2022/01/04/build-and-deploy-automatically.html index da68e25..bce1820 100644 --- a/2022/01/04/build-and-deploy-automatically.html +++ b/2022/01/04/build-and-deploy-automatically.html @@ -371,7 +371,7 @@

We are done with the Actions part. You can see the final code here. When you are also done with the code, just push it to trigger the action.

-

Now that we set up our Action to build the site, we need to let our server know about the changes so that we it pull the changes.

+

Now that we set up our Action to build the site, we need to let our server know about the changes so that it can pull the changes.

Creating a Webhook from GitHub

@@ -434,10 +434,11 @@ python3 -m venv venv if __name__ == "__main__": application.run(host='0.0.0.0') -

I will not go into details explaining what each line does. Basically, we are checking if the request is a POST request and if so we are comparing the secret keys to make sure that the request is coming from GitHub. In our case, this is not too important because when the keys match we are running a simple git pull command in our repository but you might need it if you are doing something more complicated. And here is the contents of perform-git-pull.sh file:

+

I will not go into details explaining what each line does. Basically, we are checking if the request is a POST request and if so we are comparing the secret keys to make sure that the request is coming from GitHub. In our case, this is not too important because when the keys match we are running simple git commands in our repository but you might need it if you are doing something more complicated. And here is the contents of perform-git-pull.sh file:

#!/bin/bash
 
 cd $1
+git checkout gh-pages
 git pull
 

We are almost done! All we need to do is create a service to automatically run our code and let nginx handle our endpoint correctly.

diff --git a/feed.xml b/feed.xml index 3f1b0af..48a568f 100644 --- a/feed.xml +++ b/feed.xml @@ -1,4 +1,4 @@ -Jekyll2022-01-04T23:35:06+00:00https://sahinakkaya.dev/feed.xmlŞahin Akkaya’s Personal PageŞahin Akkaya's personal blog - a perfectionist who likes to tinker everything until it is just right. Get ready to find some sweet tips that will boost your productivity and make you fall in love with your computer.Şahin AkkayaAutomatically Build and Deploy Your Site using GitHub Actions and Webhooks2022-01-04T17:40:00+00:002022-01-04T17:40:00+00:00https://sahinakkaya.dev/2022/01/04/build-and-deploy-automatically<p>In this post I will explain how you can use GitHub to automate the build and deployment processes that you have. I am going to automate the deployment of this site but you can do whatever you want. Just understanding the basics will be enough.</p> +Jekyll2022-01-05T05:21:23+00:00https://sahinakkaya.dev/feed.xmlŞahin Akkaya’s Personal PageŞahin Akkaya's personal blog - a perfectionist who likes to tinker everything until it is just right. Get ready to find some sweet tips that will boost your productivity and make you fall in love with your computer.Şahin AkkayaAutomatically Build and Deploy Your Site using GitHub Actions and Webhooks2022-01-04T17:40:00+00:002022-01-04T17:40:00+00:00https://sahinakkaya.dev/2022/01/04/build-and-deploy-automatically<p>In this post I will explain how you can use GitHub to automate the build and deployment processes that you have. I am going to automate the deployment of this site but you can do whatever you want. Just understanding the basics will be enough.</p> <h2 id="introduction-to-github-actions-and-webhooks">Introduction to GitHub Actions and Webhooks</h2> <p>Let me start by explaining what are GitHub Actions and GitHub Webhooks.</p> @@ -59,7 +59,7 @@ <p>We are done with the Actions part. You can see the final code <a href="https://github.com/Asocia/sahinakkayadotdev/blob/main/.github/workflows/jekyll.yml">here</a>. When you are also done with the code, just push it to trigger the action.</p> <h3 id="setting-up-the-webhook-and-related-endpoint">Setting up the Webhook and related endpoint</h3> -<p>Now that we set up our Action to build the site, we need to let our server know about the changes so that we it pull the changes.</p> +<p>Now that we set up our Action to build the site, we need to let our server know about the changes so that it can pull the changes.</p> <h4 id="creating-a-webhook-from-github">Creating a Webhook from GitHub</h4> @@ -122,10 +122,11 @@ python3 <span class="nt">-m</span> venv venv <span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">"__main__"</span><span class="p">:</span> <span class="n">application</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="s">'0.0.0.0'</span><span class="p">)</span> </code></pre></div></div> -<p>I will not go into details explaining what each line does. Basically, we are checking if the request is a POST request and if so we are comparing the secret keys to make sure that the request is coming from GitHub. In our case, this is not too important because when the keys match we are running a simple <code class="language-plaintext highlighter-rouge">git pull</code> command in our repository but you might need it if you are doing something more complicated. And here is the contents of <code class="language-plaintext highlighter-rouge">perform-git-pull.sh</code> file:</p> +<p>I will not go into details explaining what each line does. Basically, we are checking if the request is a POST request and if so we are comparing the secret keys to make sure that the request is coming from GitHub. In our case, this is not too important because when the keys match we are running simple git commands in our repository but you might need it if you are doing something more complicated. And here is the contents of <code class="language-plaintext highlighter-rouge">perform-git-pull.sh</code> file:</p> <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/bin/bash</span> <span class="nb">cd</span> <span class="nv">$1</span> +git checkout gh-pages git pull </code></pre></div></div> <p>We are almost done! All we need to do is create a service to automatically run our code and let nginx handle our endpoint correctly.</p>