Skip to content

Commit

Permalink
Update CD to automatically deploy the website after build
Browse files Browse the repository at this point in the history
  • Loading branch information
Antiz96 committed Nov 15, 2024
1 parent 8b710dd commit 4247e66
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
name: CD
on: pull_request
on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
Build:
if: github.event_name == 'pull_request'
runs-on:
- self-hosted
- CI-CD
Expand Down Expand Up @@ -34,3 +41,19 @@ jobs:
else
echo "No changes to commit"
fi
Deploy:
runs-on:
- self-hosted
- CI-CD

- 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, make sure you opened your pull request from the 'dev' branch"
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 (but it still gives a fairly good idea of a simple but effective CI / CD workflow one could apply to their projects). 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

0 comments on commit 4247e66

Please sign in to comment.