/
config.yml
66 lines (54 loc) · 1.62 KB
/
config.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
66
version: 2.1
executors:
hugo-executor:
docker:
- image: cibuilds/hugo:latest
jobs:
build:
executor: hugo-executor
steps:
- checkout
- run:
name: Update theme
command: git submodule update --init --recursive
- run:
name: Build Hugo site
command: hugo --destination=workspace/public
# Persist the 'build' directory to the workspace
- persist_to_workspace:
root: workspace
paths:
- public
push build:
executor: hugo-executor
steps:
- attach_workspace:
at: workspace
- run:
name: Push build folder to GitHub
command: |
# Configure Git identity
git config --global user.name "olawanlejoel"
git config --global user.email "olawanlejoel@users.noreply.github.com"
# Clone the repository (replace <your-repo> with your actual repository URL)
git clone --branch deploy --depth 1 https://olawanlejoel:${GITHUB_TOKEN}@github.com/olawanlejoel/hugo-try-circleci.git deployment
# Copy the 'public' directory to the deployment folder
cp -R workspace/public deployment
# Navigate to the deployment folder
cd deployment
# Commit and push changes
git add .
git commit -m "Auto generated from ${CIRCLE_SHA1}"
git push
workflows:
version: 2
build-and-deploy:
jobs:
- build:
filters:
branches:
only:
- main
- push build:
requires:
- build