-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.clog.yaml
More file actions
156 lines (145 loc) · 6.21 KB
/
Copy path.clog.yaml
File metadata and controls
156 lines (145 loc) · 6.21 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
---
# yamllint disable rule:colons
# ___ _ _ _ __ __
# | _ \ (_) | || | _ _ \ \ / /
# | _/ | | | __ | | || | \ \/\/ /
# |_| |_| |_||_| \_,_| \_/\_/
# =============================================================================
# -----------------------------------------------------------------------------
kfg:
# path to the yaml file defining release history - see semver package
releases-path: "assets/data/releases.yaml"
clog:
# legacy - can be deleted
releases-path: "assets/data/releases.yaml"
# _ _
# ||_ _ _ (_) _ __ _ __ ___ | |_ ___
# (_-< | ' \ | | | '_ \ | '_ \ / -_) | _| (_-<
# / _/ |_||_| |_| | .__/ | .__/ \___| \__| /__/
# || |_| |_|
# -----------------------------------------------------------------------------
snippets:
# build control logic for this repo - all commands start with bc
# dev or prod rules:
# default - always dev unless build: prod in bc-releases-yaml
# rules
# - build+deploy- if github_event=="create" then checkout to main
# - prod deploy - main branch or empty(default) branch only
# - prod deploy - main repo (not fork) only
# override
# - MAKE prod - forces production (and overrides MAKE dev)
# - MAKE dev - forces development
# clog bc-prod-logic-xx returns "dev|prod"+"(reasonString)"
bc-releases-yaml: yq -r '.clog."releases-path"' clogrc/clog.yaml
bc-main-repo: echo "metarex-media/www-metarex-media"
# ---------------------------------------------------------------------------------------------------------
watch: |
[ ! -d content ] && ln -s documentation/content content
hugo server --port=1313 --logLevel debug --buildDrafts --buildFuture --buildExpired --cleanDestinationDir
rm content
github-page: |
# Publish the pihuw documentation site to GitHub Pages.
# Works locally (requires gh CLI) or as a GitHub Actions workflow step.
# Safe to run repeatedly — creates the gh-pages branch if absent.
set -euo pipefail
REPO="mrmxf/pihuw"
BRANCH="gh-pages"
BUILD_DIR="public"
# --- always run from the repo root ---------------------------------------
ROOT="$(git rev-parse --show-toplevel)"
cd "$ROOT"
# --- install gh CLI if missing -------------------------------------------
if ! command -v gh &>/dev/null; then
echo "gh not found — running clog install gh"
clog install gh
fi
# --- pass token to gh automatically (gh reads GH_TOKEN, no login needed) -
export GH_TOKEN="${GH_TOKEN:-${GITHUB_TOKEN:-}}"
# --- ensure gh-pages branch exists on remote (first-time setup) ----------
CURRENT_BRANCH="$(git branch --show-current)"
if ! git ls-remote --exit-code --heads origin "$BRANCH" &>/dev/null; then
echo "Creating orphan branch $BRANCH on remote"
git fetch origin || true
git checkout --orphan "$BRANCH"
git reset --hard
git commit --allow-empty -m "chore: initialise GitHub Pages branch"
git push origin "$BRANCH"
git checkout "$CURRENT_BRANCH"
gh api repos/"$REPO"/pages \
--method POST \
--field source[branch]="$BRANCH" \
--field source[path]="/" \
--silent || echo "Pages source already configured"
fi
# --- build the site ------------------------------------------------------
# trap ensures the content symlink is removed even if hugo fails
cleanup() { [ -L content ] && rm content; }
trap cleanup EXIT
echo "Building Hugo site"
[ ! -L content ] && ln -s documentation/content content
hugo --minify --cleanDestinationDir
# --- deploy to gh-pages --------------------------------------------------
echo "Deploying to $BRANCH"
cd "$BUILD_DIR"
git init -b "$BRANCH"
git remote add origin "$(git -C .. remote get-url origin)"
git add -A
git commit -m "chore: deploy documentation $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
git push --force origin "$BRANCH"
cd ..
rm -rf "$BUILD_DIR"
# --- print the Pages URL -------------------------------------------------
URL=$(gh api repos/"$REPO"/pages --jq '.html_url' 2>/dev/null || echo "https://mrmxf.github.io/pihuw")
echo "Published → $URL"
git:
tag:
# pihuw, like Hugo & golang requires a "v"
ref: echo "v$(yq -r '.[0].version' "$(clog bc-releases-yaml)")"
# a go package needs a preceding "v"
refgo: echo "v$(clog git tag ref)"
message:
ref: yq -r '.[0].note' assets/data/releases.yaml
suffix: |
b="$(git branch --show-current)"
[[ "$b" == main ]] && echo "" || echo "$b"|tr -d '[:blank:]'"
project:
config: |
PROJECT=pihuw
DOCKER_NS=mrmxf
has:
fomantic: cat layouts/_partials/tmpl/head-cdn|grep -oE '[0-9]+\.[0-9]+\.[0-9]+'|tail -1
hugo: hugo version|grep -oE '[0-9]\.[0-9]+\.[0-9]+'
git-lfs: git-lfs version|grep -oE '[0-9]\.[0-9]+\.[0-9]+'|head -1
needs:
# grab the golang version from go.mod
golang: cat go.mod|grep '^go '|grep -oE '[0-9]\.[0-9]+\.[0-9]+'
# hunt for the hugo version
hugo: |
# grab the version from configuration
if [ -f hugo .yaml ];then
yq -r '.module.hugoVersion.min' hugo.yaml
elif [ -f config/_default/module.yaml ];then
yq -r '.hugoVersion.min' config/_default/module.yaml
else
echo "hugo config not found"
fi
git-lfs: echo "3.6.0"
# =============================================================================
# ___ _ _
# / __| | |_ ___ __ | |__
# | (__ | ' \ / -_) / _| | / /
# \___| |_||_| \___| \__| |_\_\
# -----------------------------------------------------------------------------
check:
build:
blocks:
- name: hugo version
try: |
[[ "$(clog project needs hugo)" == "$(clog project has hugo)" ]]
ok: clog Log -I "hugo $(clog project has hugo) is up to date"
catch: |
clog Log -W "hugo: bad version. Need $(clog project needs hugo), got $(clog project has hugo)"
- name: content folder
try: "[ ! -d content ]"
ok: clog Log -I "content folder not linked"
catch: eval "$(clog Inc)";clog Log -E "content folder exists -$cC ln$cW -d$cF content"