Skip to content

Commit dff555d

Browse files
committed
update simulator
1 parent ef10da7 commit dff555d

File tree

3 files changed

+64
-25
lines changed

3 files changed

+64
-25
lines changed

.github/workflows/process_docs_changes.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,7 @@ jobs:
114114

115115
- name: Merge control files from Marketing Repo
116116
run: |
117-
cp -r .marketing_repo/_data .
118-
cp -r .marketing_repo/_includes .
119-
cp -r .marketing_repo/_layouts .
120-
cp -r .marketing_repo/_plugins .
121-
cp -r .marketing_repo/_sass .
117+
bb script/sync-repo.clj --from .marketing_repo
122118
123119
- name: "yarn lint-markdown"
124120
run: |

script/_test/simulator.sh

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,49 @@
99

1010
set -euo pipefail
1111

12-
echo "Running simulator.sh on branch: $MAIN_REPO_BRANCH"
13-
14-
printf '\n\n\n============================== bb script/_test/all.clj ==============================z\n'
12+
echo "Prerequisites"
13+
echo ""
14+
echo "Installed:"
15+
echo " - Ruby (>= 2.7.0)"
16+
echo " - Jekyll (>= 3.8.5)"
17+
echo " - Bundler (>= 2.0.1)"
18+
echo " - Node.js (>= 12.0.0)"
19+
echo " - Yarn (>= 1.22.0)"
20+
echo " - Babashka"
21+
echo ""
22+
echo "Directory Structure:"
23+
echo " - metabase.github.io (the marketing repo) should be at ../metabase.github.io relative to the root of this repo"
24+
echo ""
25+
echo "Running simulator.sh on branch: $TARGET_BRANCH"
26+
27+
printf '\n\n\n================= bb script/_test/all.clj =================z\n'
1528
bb script/_test/all.clj
1629

17-
printf '\n\n\n============================== bb script/check_incoming_branchname.clj "$MAIN_REPO_BRANCH" ==============================z\n'
18-
bb script/check_incoming_branchname.clj "$MAIN_REPO_BRANCH"
19-
20-
printf '\n\n\n============================== bb script/update_docs_for_branchname.clj "$MAIN_REPO_BRANCH" ==============================z\n'
21-
bb script/update_docs_for_branchname.clj "$MAIN_REPO_BRANCH"
30+
printf "\n\n\n================= bb script/check_incoming_branchname.clj --target-branch %s =================z\n" "$TARGET_BRANCH"
31+
bb script/check_incoming_branchname.clj --target-branch "$TARGET_BRANCH"
2232

23-
printf '\n\n\n============================== copy marketing files ==============================z\n'
33+
printf "\n\n\n================= bb script/update_docs_for_branchname.clj --source-branch %s --target-branch %s =================z\n" "$SOURCE_BRANCH" "$TARGET_BRANCH"
34+
bb script/update_docs_for_branchname.clj --source-branch "$SOURCE_BRANCH" --target-branch "$TARGET_BRANCH"
2435

25-
cp -r ../metabase.github.io/_data .
26-
cp -r ../metabase.github.io/_includes .
27-
cp -r ../metabase.github.io/_community-posts .
28-
cp -r ../metabase.github.io/_layouts .
29-
cp -r ../metabase.github.io/_plugins .
30-
cp -r ../metabase.github.io/_sass .
36+
printf '\n\n\n================= copy marketing files =================z\n'
37+
bb script/sync_repo.clj --from-repo ../metabase.github.io
3138

32-
printf '\n\n\n============================== yarn lint-markdown ==============================z\n'
39+
printf '\n\n\n================= yarn lint-markdown =================z\n'
3340
yarn lint-markdown
3441

35-
printf '\n\n\n============================== yarn lint-styles ==============================z\n'
42+
printf '\n\n\n================= yarn lint-styles =================z\n'
3643
yarn lint-styles
3744

38-
printf '\n\n\n============================== yarn lint-scripts ==============================z\n'
45+
printf '\n\n\n================= yarn lint-scripts =================z\n'
3946
yarn lint-scripts
4047

41-
printf '\n\n\n============================== yarn lint-links ==============================z\n'
48+
printf '\n\n\n================= yarn lint-links =================z\n'
4249
yarn lint-links
4350

4451
# Clear the existing site:
4552
rm -rf _site
4653

47-
# Build the jekyll site:
54+
# Build the docs jekyll site:
4855
bundle exec jekyll build
4956

5057
script/links || true

script/sync_repo.clj

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
(ns sync-repo
2+
(:require
3+
[clojure.string :as str]
4+
[babashka.cli :as cli]
5+
[babashka.fs :as fs]
6+
[util :as u]))
7+
8+
9+
;; bb script/sync_repo.clj --from .marketing_repo
10+
11+
(def cli-spec
12+
{:spec {:from-repo {:ref "<target-branch>"
13+
:desc "The target branch of the triggering PR."
14+
:require true}}
15+
:error-fn u/cli-error-fn})
16+
17+
(def control-dirs
18+
["_data"
19+
"_includes"
20+
"_layouts"
21+
"_plugins"
22+
"_sass"
23+
"js"
24+
"redirects"])
25+
26+
(defn -main [& args]
27+
(let [{:keys [from-repo] :as x} (cli/parse-opts args cli-spec)]
28+
(doseq [dir control-dirs]
29+
(let [source-dir (fs/file from-repo dir)
30+
target-dir dir]
31+
(when (fs/exists? source-dir)
32+
(println "Syncing" (str source-dir) "to" (str target-dir))
33+
(fs/copy source-dir target-dir {:replace-existing true}))))))
34+
35+
(when (= *file* (System/getProperty "babashka.file"))
36+
(apply -main *command-line-args*))

0 commit comments

Comments
 (0)