Skip to content

Commit 82ddef9

Browse files
committed
filter out non-documented branches
1 parent 4c6289e commit 82ddef9

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.github/workflows/process_docs_changes.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ jobs:
3434
with:
3535
babashka-version: 1.12.199
3636

37+
- name: Filter non-documented branches
38+
run: |
39+
bb script/check_incoming_branchname.clj $MAIN_REPO_BRANCH
40+
3741
- name: Install js dependencies
3842
run: yarn install --frozen-lockfile --prefer-offline
3943

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(ns check-incoming-branchname)
2+
3+
(defn usage []
4+
(println "Usage: script/check_incoming_branchname.clj branchname")
5+
(System/exit 1))
6+
7+
(def release-regex #"release-x\.(\d+)\.x")
8+
9+
(defn extract-release-num [release-branchname]
10+
(let [[_ num] (re-matches release-regex release-branchname)]
11+
num))
12+
13+
(defn categorize-branchname [branchname]
14+
(cond
15+
(= branchname "master") [:master]
16+
(re-matches release-regex branchname) [:release (extract-release-num branchname)]))
17+
18+
(defn -main
19+
"This is called from the `process_docs_changes.yml` workflow. It checks that
20+
the branchname is either `master` or a release branch. If not, it exits with
21+
an error code, stopping the workflow before it goes ahead and opens a PR with
22+
the docs changes."
23+
[& args]
24+
(let [branchname (or (first args) (usage))
25+
_ (println "Checking branchname:" branchname)
26+
[category release-num] (categorize-branchname branchname)]
27+
(case category
28+
:master (println "Master branch detected.")
29+
:release (println "Release branch detected:" release-num)
30+
(do (println "Unpublishable branchname: " branchname)
31+
(System/exit 1)))))
32+
33+
(when (= *file* (System/getProperty "babashka.file"))
34+
(apply -main *command-line-args*))

0 commit comments

Comments
 (0)