Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #75

Closed
wants to merge 3 commits into from
Closed

Dev #75

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 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,20 @@ jobs:
else
echo "No changes to commit"
fi

Deploy:
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, 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