From 1ba7412e30112549375ef2ea6f58721f56455705 Mon Sep 17 00:00:00 2001 From: Asocia Date: Tue, 4 Jan 2022 23:35:06 +0000 Subject: [PATCH] jekyll build from Action b9597b9e5c83411cf16ed32a0b65d129e863f4f4 --- 2022/01/04/build-and-deploy-automatically.html | 14 ++++++++------ feed.xml | 16 +++++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/2022/01/04/build-and-deploy-automatically.html b/2022/01/04/build-and-deploy-automatically.html index 350b94b..da68e25 100644 --- a/2022/01/04/build-and-deploy-automatically.html +++ b/2022/01/04/build-and-deploy-automatically.html @@ -371,21 +371,21 @@

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 can pull them.

+

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.

Creating a Webhook from GitHub

To add a Webhook, open your repository in browser and navigate to ‘Settings > Webhooks’ and click ‘Add Webhook’. Fill in the form with appropriate values. Here is an example: Webhook form example

-

This is all you have to do from GitHub. Now, whenever there is a push event to our repository, GitHub will send a POST request to our payload url with the details.

+

This is all you have to do from GitHub. Now, whenever there is a push event to your repository, GitHub will send a POST request to your payload url with the details.

Note: Our Action is configured to push to a branch in our repository, so it will also trigger this hook and we will catch it.

Creating an endpoint to handle the requests

-

I will use Flask framework to handle the post requests coming to our endpoint. You can use whatever programming language or framework you want. It will be very simple code with just one job.

+

I will use Flask framework to handle the post requests coming to our endpoint. You can use whatever programming language or framework you want. It will be very simple code with just one job: Validate the secret keys and run a specific code.

-

Create a new project, and a virtual environment:

+

Let’s start by creating a new project, and a virtual environment:

mdkir post_receiver
 cd post_receiver
 python3 -m venv venv
@@ -442,8 +442,10 @@ 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.

-

Create a new file post_receiver.service in /etc/systemd/system:

-
# change <user> to your actual username
+

Create a new file post_receiver.service in /etc/systemd/system/:

+
#/etc/systemd/system/post_receiver.service
+
+# change <user> to your actual username
 [Unit]
 Description=post_receiver
 After=network.target multi-user.target
diff --git a/feed.xml b/feed.xml
index 4b6005a..3f1b0af 100644
--- a/feed.xml
+++ b/feed.xml
@@ -1,4 +1,4 @@
-Jekyll2022-01-04T23:26:11+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-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>
 
 <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,21 +59,21 @@
 <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 can pull them.</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 we it pull the changes.</p>
 
 <h4 id="creating-a-webhook-from-github">Creating a Webhook from GitHub</h4>
 
 <p>To add a Webhook, open your repository in browser and navigate to <em>‘Settings &gt; Webhooks’</em> and click <em>‘Add Webhook’</em>. Fill in the form with appropriate values. Here is an example:
 <img src="/assets/images/gh-actions-and-webhooks/add-webhook.png" alt="Webhook form example" /></p>
 
-<p>This is all you have to do from GitHub. Now, whenever there is a <em><code class="language-plaintext highlighter-rouge">push</code></em> event to our repository, GitHub will send a POST request to our <em>payload url</em> with the details.</p>
+<p>This is all you have to do from GitHub. Now, whenever there is a <em><code class="language-plaintext highlighter-rouge">push</code></em> event to your repository, GitHub will send a POST request to your <em>payload url</em> with the details.</p>
 
 <p class="notice--info"><strong>Note:</strong> Our Action is configured to push to a branch in our repository, so it will also trigger this hook and we will catch it.</p>
 
 <h4 id="creating-an-endpoint-to-handle-the-requests">Creating an endpoint to handle the requests</h4>
-<p>I will use <a href="https://flask.palletsprojects.com/en/2.0.x/">Flask</a> framework to handle the post requests coming to our endpoint. You can use whatever programming language or framework you want. It will be very simple code with just one job.</p>
+<p>I will use <a href="https://flask.palletsprojects.com/en/2.0.x/">Flask</a> framework to handle the post requests coming to our endpoint. You can use whatever programming language or framework you want. It will be very simple code with just one job: Validate the secret keys and run a specific code.</p>
 
-<p>Create a new project, and a virtual environment:</p>
+<p>Let’s start by creating a new project, and a virtual environment:</p>
 <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mdkir post_receiver
 <span class="nb">cd </span>post_receiver
 python3 <span class="nt">-m</span> venv venv
@@ -130,8 +130,10 @@ 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>
 
-<p>Create a new file <code class="language-plaintext highlighter-rouge">post_receiver.service</code> in <code class="language-plaintext highlighter-rouge">/etc/systemd/system</code>:</p>
-<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># change &lt;user&gt; to your actual username
+<p>Create a new file <code class="language-plaintext highlighter-rouge">post_receiver.service</code> in <code class="language-plaintext highlighter-rouge">/etc/systemd/system/</code>:</p>
+<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#/etc/systemd/system/post_receiver.service
+
+# change &lt;user&gt; to your actual username
 [Unit]
 Description=post_receiver
 After=network.target multi-user.target