Skip to content

Commit

Permalink
Update CD to automatically deploy the website after build (#76)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: GitHub Actions <[email protected]>
  • Loading branch information
Antiz96 and actions-user authored Nov 15, 2024
1 parent 8b710dd commit 7492967
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 48 deletions.
33 changes: 31 additions & 2 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: CD
on: pull_request
on:
pull_request:
push:
branches:
- main

jobs:
Build:
Checkout:
runs-on:
- self-hosted
- CI-CD
Expand All @@ -14,6 +18,13 @@ jobs:
token: ${{ secrets.BUILD_WEBSITE_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }}

Build:
needs: Checkout
runs-on:
- self-hosted
- CI-CD

steps:
- name: Init theme submodule
run: git submodule update --init

Expand All @@ -34,3 +45,21 @@ jobs:
else
echo "No changes to commit"
fi
Deploy:
needs: Build
runs-on:
- self-hosted
- CI-CD

steps:
- name: Deploy website
run: |
if [ "$(git rev-parse --abbrev-ref HEAD)" == "dev" ]; then
/opt/github-runner/antiz.fr/deploy_website.sh dev
elif [ "$(git rev-parse --abbrev-ref HEAD)" == "main" ]; then
/opt/github-runner/antiz.fr/deploy_website.sh prod
else
echo "Invalid branch, nothing to deploy"
exit 1
fi
4 changes: 3 additions & 1 deletion content/blog/website-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ date: 2023-07-24T13:20:26+02:00
draft: false
---

EDIT: This article is slitghly outdated as the workflow I use to maintain this website has evolved and improved over time. I'll eventually write a V2 of that article at some point.

## The website

This website is built with the [HUGO](https://gohugo.io/) static website generator using the [anatole](https://github.com/lxndrblz/anatole) theme.
Expand Down Expand Up @@ -34,7 +36,7 @@ The [test job](https://github.com/Antiz96/antiz.fr/blob/main/.github/workflows/C

### CD

Once both of the above CI jobs succeeded (meaning the website has been successfully built, pushed to the dev branch of the repository, and the tests went through without any error), I launch a job on my [Jenkins](https://www.jenkins.io/) server targeting the dev environment:
Once both of the above CI jobs succeeded (meaning the website has been successfully built, pushed to the dev branch of the repository, and the tests went through without any error), I launch a job on my [Jenkins](https://www.jenkins.io/) server targeting the dev environment *(edit: the trigger of that job is now automated via GitHub actions as well):

![alt_text](../../images/Jenkins_Update_Website_Job_Dev.png "Jenkins - Update Website Job Dev")

Expand Down
2 changes: 1 addition & 1 deletion public/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

</title>

<meta name="generator" content="Hugo 0.136.2"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="generator" content="Hugo 0.138.0"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="author" content="Robin Candau" />
<meta
name="description"
Expand Down
12 changes: 4 additions & 8 deletions public/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

</title>

<meta name="generator" content="Hugo 0.136.2"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="generator" content="Hugo 0.138.0"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="author" content="Robin Candau" />
<meta
name="description"
Expand Down Expand Up @@ -387,14 +387,10 @@
<div class="post__content">
<a class="" href="/blog/website-workflow/" title="The automated workflow I use to manage this website"><h3>The automated workflow I use to manage this website</h3></a>
<div class="post__footer">24 July 2023</div>
<p><h2 id="the-website">The website</h2>
<p><p>EDIT: This article is slitghly outdated as the workflow I use to maintain this website has evolved and improved over time. I&rsquo;ll eventually write a V2 of that article at some point.</p>
<h2 id="the-website">The website</h2>
<p>This website is built with the <a href="https://gohugo.io/">HUGO</a> static website generator using the <a href="https://github.com/lxndrblz/anatole">anatole</a> theme.<br>
The website&rsquo;s source code is hosted in <a href="https://github.com/Antiz96/antiz.fr/">this GitHub repository</a>.</p>
<h2 id="automated-workflow">Automated workflow</h2>
<p>To manage this website, I use an automated CI / CD workflow:</p>
<h3 id="ci">CI</h3>
<p>I make my changes <em>(creating an new article, update the theme, add new parameters to the website, etc&hellip;)</em> locally on my computer inside the git repository in the dev branch.<br>
Once the changes are done, I push them to the GitHub repository and I create a pull request from the dev branch to the main one, which triggers a CI pipeline:</p></p>
The website&rsquo;s source code is hosted in <a href="https://github.com/Antiz96/antiz.fr/">this GitHub repository</a>.</p></p>
<p>[...]</p>
<a class="custom-readmore" href="/blog/website-workflow/" title="The automated workflow I use to manage this website">Read More</a>
</div>
Expand Down
10 changes: 3 additions & 7 deletions public/blog/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,10 @@ After a quick thought, I understood that a power outage occurred during the nigh

<guid>https://antiz.fr/blog/website-workflow/</guid>

<description>&lt;h2 id=&#34;the-website&#34;&gt;The website&lt;/h2&gt;
<description>&lt;p&gt;EDIT: This article is slitghly outdated as the workflow I use to maintain this website has evolved and improved over time. I&amp;rsquo;ll eventually write a V2 of that article at some point.&lt;/p&gt;
&lt;h2 id=&#34;the-website&#34;&gt;The website&lt;/h2&gt;
&lt;p&gt;This website is built with the &lt;a href=&#34;https://gohugo.io/&#34;&gt;HUGO&lt;/a&gt; static website generator using the &lt;a href=&#34;https://github.com/lxndrblz/anatole&#34;&gt;anatole&lt;/a&gt; theme.&lt;br&gt;
The website&amp;rsquo;s source code is hosted in &lt;a href=&#34;https://github.com/Antiz96/antiz.fr/&#34;&gt;this GitHub repository&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;automated-workflow&#34;&gt;Automated workflow&lt;/h2&gt;
&lt;p&gt;To manage this website, I use an automated CI / CD workflow:&lt;/p&gt;
&lt;h3 id=&#34;ci&#34;&gt;CI&lt;/h3&gt;
&lt;p&gt;I make my changes &lt;em&gt;(creating an new article, update the theme, add new parameters to the website, etc&amp;hellip;)&lt;/em&gt; locally on my computer inside the git repository in the dev branch.&lt;br&gt;
Once the changes are done, I push them to the GitHub repository and I create a pull request from the dev branch to the main one, which triggers a CI pipeline:&lt;/p&gt;</description>
The website&amp;rsquo;s source code is hosted in &lt;a href=&#34;https://github.com/Antiz96/antiz.fr/&#34;&gt;this GitHub repository&lt;/a&gt;.&lt;/p&gt;</description>

</item>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

</title>

<meta name="generator" content="Hugo 0.136.2"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="generator" content="Hugo 0.138.0"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="author" content="Robin Candau" />
<meta
name="description"
Expand Down
2 changes: 1 addition & 1 deletion public/blog/raspberry-pi-wake-on-lan-server/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

</title>

<meta name="generator" content="Hugo 0.136.2"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="generator" content="Hugo 0.138.0"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="author" content="Robin Candau" />
<meta
name="description"
Expand Down
27 changes: 12 additions & 15 deletions public/blog/website-workflow/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

</title>

<meta name="generator" content="Hugo 0.136.2"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="generator" content="Hugo 0.138.0"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="author" content="Robin Candau" />
<meta
name="description"
Expand Down Expand Up @@ -127,23 +127,19 @@

<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="The automated workflow I use to manage this website">
<meta name="twitter:description" content="The website This website is built with the HUGO static website generator using the anatole theme.
The website’s source code is hosted in this GitHub repository.
Automated workflow To manage this website, I use an automated CI / CD workflow:
CI I make my changes (creating an new article, update the theme, add new parameters to the website, etc…) locally on my computer inside the git repository in the dev branch.
Once the changes are done, I push them to the GitHub repository and I create a pull request from the dev branch to the main one, which triggers a CI pipeline:">
<meta name="twitter:description" content="EDIT: This article is slitghly outdated as the workflow I use to maintain this website has evolved and improved over time. I’ll eventually write a V2 of that article at some point.
The website This website is built with the HUGO static website generator using the anatole theme.
The website’s source code is hosted in this GitHub repository.">




<meta property="og:url" content="https://antiz.fr/blog/website-workflow/">
<meta property="og:site_name" content="Robin Candau">
<meta property="og:title" content="The automated workflow I use to manage this website">
<meta property="og:description" content="The website This website is built with the HUGO static website generator using the anatole theme.
The website’s source code is hosted in this GitHub repository.
Automated workflow To manage this website, I use an automated CI / CD workflow:
CI I make my changes (creating an new article, update the theme, add new parameters to the website, etc…) locally on my computer inside the git repository in the dev branch.
Once the changes are done, I push them to the GitHub repository and I create a pull request from the dev branch to the main one, which triggers a CI pipeline:">
<meta property="og:description" content="EDIT: This article is slitghly outdated as the workflow I use to maintain this website has evolved and improved over time. I’ll eventually write a V2 of that article at some point.
The website This website is built with the HUGO static website generator using the anatole theme.
The website’s source code is hosted in this GitHub repository.">
<meta property="og:locale" content="en_us">
<meta property="og:type" content="article">
<meta property="article:section" content="blog">
Expand All @@ -166,7 +162,7 @@
"alternativeHeadline": "",
"description": "
\u003ch2 id=\u0022the-website\u0022\u003eThe website\u003c\/h2\u003e\n\u003cp\u003eThis website is built with the \u003ca href=\u0022https:\/\/gohugo.io\/\u0022\u003eHUGO\u003c\/a\u003e static website generator using the \u003ca href=\u0022https:\/\/github.com\/lxndrblz\/anatole\u0022\u003eanatole\u003c\/a\u003e theme.\u003cbr\u003e\nThe website\u0026rsquo;s source code is hosted in \u003ca href=\u0022https:\/\/github.com\/Antiz96\/antiz.fr\/\u0022\u003ethis GitHub repository\u003c\/a\u003e.\u003c\/p\u003e\n\u003ch2 id=\u0022automated-workflow\u0022\u003eAutomated workflow\u003c\/h2\u003e\n\u003cp\u003eTo manage this website, I use an automated CI \/ CD workflow:\u003c\/p\u003e\n\u003ch3 id=\u0022ci\u0022\u003eCI\u003c\/h3\u003e\n\u003cp\u003eI make my changes \u003cem\u003e(creating an new article, update the theme, add new parameters to the website, etc\u0026hellip;)\u003c\/em\u003e locally on my computer inside the git repository in the dev branch.\u003cbr\u003e\nOnce the changes are done, I push them to the GitHub repository and I create a pull request from the dev branch to the main one, which triggers a CI pipeline:\u003c\/p\u003e
\u003cp\u003eEDIT: This article is slitghly outdated as the workflow I use to maintain this website has evolved and improved over time. I\u0026rsquo;ll eventually write a V2 of that article at some point.\u003c\/p\u003e\n\u003ch2 id=\u0022the-website\u0022\u003eThe website\u003c\/h2\u003e\n\u003cp\u003eThis website is built with the \u003ca href=\u0022https:\/\/gohugo.io\/\u0022\u003eHUGO\u003c\/a\u003e static website generator using the \u003ca href=\u0022https:\/\/github.com\/lxndrblz\/anatole\u0022\u003eanatole\u003c\/a\u003e theme.\u003cbr\u003e\nThe website\u0026rsquo;s source code is hosted in \u003ca href=\u0022https:\/\/github.com\/Antiz96\/antiz.fr\/\u0022\u003ethis GitHub repository\u003c\/a\u003e.\u003c\/p\u003e
Expand Down Expand Up @@ -216,7 +212,7 @@

,
"url" : "https:\/\/antiz.fr\/blog\/website-workflow\/",
"wordCount" : "372",
"wordCount" : "418",
"genre" : [ ],
"keywords" : [ ]
}
Expand Down Expand Up @@ -439,7 +435,8 @@ <h1>The Automated Workflow I Use to Manage This Website</h1>
<span class="post__meta-text">2-minute read</span>
</li>
</ul>
<h2 id="the-website">The website</h2>
<p>EDIT: This article is slitghly outdated as the workflow I use to maintain this website has evolved and improved over time. I&rsquo;ll eventually write a V2 of that article at some point.</p>
<h2 id="the-website">The website</h2>
<p>This website is built with the <a href="https://gohugo.io/">HUGO</a> static website generator using the <a href="https://github.com/lxndrblz/anatole">anatole</a> theme.<br>
The website&rsquo;s source code is hosted in <a href="https://github.com/Antiz96/antiz.fr/">this GitHub repository</a>.</p>
<h2 id="automated-workflow">Automated workflow</h2>
Expand All @@ -459,7 +456,7 @@ <h3 id="ci">CI</h3>
</ul>
<p>The <a href="https://github.com/Antiz96/antiz.fr/blob/main/.github/workflows/CI.yml">test job</a> automatically runs a bunch of tests / linters against the website&rsquo;s files in the repository, to make sure the changes I made are correctly written / syntaxed.</p>
<h3 id="cd">CD</h3>
<p>Once both of the above CI jobs succeeded (meaning the website has been successfully built, pushed to the dev branch of the repository, and the tests went through without any error), I launch a job on my <a href="https://www.jenkins.io/">Jenkins</a> server targeting the dev environment:</p>
<p>Once both of the above CI jobs succeeded (meaning the website has been successfully built, pushed to the dev branch of the repository, and the tests went through without any error), I launch a job on my <a href="https://www.jenkins.io/">Jenkins</a> server targeting the dev environment *(edit: the trigger of that job is now automated via GitHub actions as well):</p>
<p><img src="../../images/Jenkins_Update_Website_Job_Dev.png" alt="alt_text" title="Jenkins - Update Website Job Dev"></p>
<p>This Jenkins job runs a simple <a href="https://www.ansible.com/">Ansible</a> playbook (see that playbook <a href="https://github.com/Antiz96/Linux-Server/blob/main/Ansible-Playbooks/roles/update_antiz.fr/tasks/main.yml">here</a>) that aims to update the website&rsquo;s sources on the targeted environment against the related GitHub branch (dev branch &ndash;&gt; development environment, main branch &ndash;&gt; production environment):</p>
<p><img src="../../images/Jenkins_Update_Website_Job_Param.png" alt="alt_text" title="Jenkins - Update Website Job Parameters"></p>
Expand Down
2 changes: 1 addition & 1 deletion public/blog/welcome/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

</title>

<meta name="generator" content="Hugo 0.136.2"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="generator" content="Hugo 0.138.0"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="author" content="Robin Candau" />
<meta
name="description"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

</title>

<meta name="generator" content="Hugo 0.136.2"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="generator" content="Hugo 0.138.0"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="author" content="Robin Candau" />
<meta
name="description"
Expand Down
2 changes: 1 addition & 1 deletion public/categories/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

</title>

<meta name="generator" content="Hugo 0.136.2"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="generator" content="Hugo 0.138.0"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="author" content="Robin Candau" />
<meta
name="description"
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

</title>

<meta name="generator" content="Hugo 0.136.2"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="generator" content="Hugo 0.138.0"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="author" content="Robin Candau" />
<meta
name="description"
Expand Down
10 changes: 3 additions & 7 deletions public/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,10 @@ After a quick thought, I understood that a power outage occurred during the nigh

<guid>https://antiz.fr/blog/website-workflow/</guid>

<description>&lt;h2 id=&#34;the-website&#34;&gt;The website&lt;/h2&gt;
<description>&lt;p&gt;EDIT: This article is slitghly outdated as the workflow I use to maintain this website has evolved and improved over time. I&amp;rsquo;ll eventually write a V2 of that article at some point.&lt;/p&gt;
&lt;h2 id=&#34;the-website&#34;&gt;The website&lt;/h2&gt;
&lt;p&gt;This website is built with the &lt;a href=&#34;https://gohugo.io/&#34;&gt;HUGO&lt;/a&gt; static website generator using the &lt;a href=&#34;https://github.com/lxndrblz/anatole&#34;&gt;anatole&lt;/a&gt; theme.&lt;br&gt;
The website&amp;rsquo;s source code is hosted in &lt;a href=&#34;https://github.com/Antiz96/antiz.fr/&#34;&gt;this GitHub repository&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;automated-workflow&#34;&gt;Automated workflow&lt;/h2&gt;
&lt;p&gt;To manage this website, I use an automated CI / CD workflow:&lt;/p&gt;
&lt;h3 id=&#34;ci&#34;&gt;CI&lt;/h3&gt;
&lt;p&gt;I make my changes &lt;em&gt;(creating an new article, update the theme, add new parameters to the website, etc&amp;hellip;)&lt;/em&gt; locally on my computer inside the git repository in the dev branch.&lt;br&gt;
Once the changes are done, I push them to the GitHub repository and I create a pull request from the dev branch to the main one, which triggers a CI pipeline:&lt;/p&gt;</description>
The website&amp;rsquo;s source code is hosted in &lt;a href=&#34;https://github.com/Antiz96/antiz.fr/&#34;&gt;this GitHub repository&lt;/a&gt;.&lt;/p&gt;</description>

</item>

Expand Down
2 changes: 1 addition & 1 deletion public/tags/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

</title>

<meta name="generator" content="Hugo 0.136.2"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="generator" content="Hugo 0.138.0"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
<meta name="author" content="Robin Candau" />
<meta
name="description"
Expand Down

0 comments on commit 7492967

Please sign in to comment.