-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (56 loc) · 1.54 KB
/
CD.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: CD
on:
pull_request:
push:
branches:
- main
jobs:
Checkout:
runs-on:
- self-hosted
- CI-CD
steps:
- name: Clone repo
uses: actions/checkout@v4
with:
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
- name: Copy custom CSS in theme
run: cp custom.css themes/anatole/assets/css/custom.css
- name: Build website
run: rm -rf public && hugo
- name: Commit automated build
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
if [ "$(git status --porcelain public)" ]; then
git add public
git commit -m "Automated build"
git push
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