Skip to content

Commit 667f257

Browse files
chore(scripts): mirror theme starters to independent repos an… (gatsbyjs#15323)
1 parent 9b3db53 commit 667f257

File tree

4 files changed

+83
-2
lines changed

4 files changed

+83
-2
lines changed

.circleci/config.yml

+26
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,25 @@ jobs:
207207
- run: git config --global user.email "[email protected]"
208208
- run: sh ./scripts/clone-and-validate.sh starters true
209209

210+
theme_starters_validate:
211+
executor: node
212+
steps:
213+
- checkout
214+
- run: ./scripts/assert-changed-files.sh "themes/*|.circleci/*"
215+
- run: sh ./scripts/clone-and-validate-theme-starters.sh
216+
217+
theme_starters_publish:
218+
executor: node
219+
steps:
220+
- checkout
221+
- <<: *restore_cache
222+
- <<: *install_node_modules
223+
- <<: *persist_cache
224+
- run: sudo apt-get update && sudo apt-get install jq # jq is helpful for parsing json
225+
- run: git config --global user.name "GatsbyJS Bot"
226+
- run: git config --global user.email "[email protected]"
227+
- run: sh ./scripts/clone-and-validate-theme-starters.sh true
228+
210229
workflows:
211230
version: 2
212231
build-test:
@@ -251,3 +270,10 @@ workflows:
251270
branches:
252271
only:
253272
- master
273+
- theme_starters_validate:
274+
<<: *ignore_master
275+
- theme_starters_publish:
276+
filters:
277+
branches:
278+
only:
279+
- master

lerna.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
}
1212
},
1313
"loglevel": "success",
14-
"packages": ["packages/*"],
14+
"packages": [
15+
"packages/*",
16+
"themes/gatsby-theme-blog",
17+
"themes/gatsby-theme-notes"
18+
],
1519
"version": "independent",
1620
"npmClient": "yarn",
1721
"registry": "https://registry.npmjs.org/",

renovate.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"extends": ["config:base"],
3-
"includePaths": ["starters/**"],
3+
"includePaths": [
4+
"starters/**",
5+
"themes/gatsby-starter-blog-theme",
6+
"themes/gatsby-starter-notes-theme",
7+
"themes/gatsby-starter-theme"
8+
],
49
"major": {
510
"enabled": false
611
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
CLONE=$1
3+
IS_CI="${CI:-false}"
4+
BASE=$(pwd)
5+
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
6+
7+
if [ "$IS_CI" = true ]; then
8+
sudo apt-get update && sudo apt-get install jq
9+
fi
10+
11+
for folder in "themes/gatsby-starter-blog-theme" "themes/gatsby-starter-notes-theme" "themes/gatsby-starter-theme"; do
12+
[ -d "$folder" ] || continue # only directories
13+
cd $BASE
14+
15+
NAME=$(cat $folder/package.json | jq -r '.name')
16+
CLONE_DIR="__${NAME}__clone__"
17+
18+
# sync to read-only clones
19+
if [ "$CLONE" = true ]; then
20+
# clone, delete files in the clone, and copy (new) files over
21+
# this handles file deletions, additions, and changes seamlessly
22+
git clone --depth 1 https://$GITHUB_API_TOKEN@github.com/gatsbyjs/$NAME.git $CLONE_DIR
23+
cd $CLONE_DIR
24+
find . | grep -v ".git" | grep -v "^\.*$" | xargs rm -rf # delete all files (to handle deletions in monorepo)
25+
cp -r $BASE/$folder/. .
26+
27+
rm -rf yarn.lock
28+
yarn import # generate a new yarn.lock file based on package-lock.json
29+
30+
git add .
31+
git commit --message "$COMMIT_MESSAGE"
32+
git push origin master
33+
else
34+
# validate
35+
cd $folder
36+
npm audit &&
37+
npm install &&
38+
# check both npm and yarn, sometimes yarn registry lags behind
39+
rm -rf node_modules &&
40+
yarn &&
41+
npm run build ||
42+
exit 1
43+
fi
44+
45+
cd $BASE
46+
done

0 commit comments

Comments
 (0)