Skip to content

Commit b2c9f12

Browse files
committed
More robust implementation
Signed-off-by: Dean Wampler <dean.wampler@ibm.com>
1 parent fa08393 commit b2c9f12

File tree

1 file changed

+59
-57
lines changed

1 file changed

+59
-57
lines changed

create-microsite.sh

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ fa_url_names["FA6"]=advocacy
3131

3232
help() {
3333
cat << EOF
34-
$script [-h|--help] [-n|--noop] --repo-name|-r name --microsite-title|--site-title|-t title --work-group|-w work_group
34+
$script [-h|--help] [-n|--noop] [--ns|--next-steps] \
35+
--repo-name|-r name --microsite-title|--site-title|-t title --work-group|-w work_group
3536
3637
Where the options and required arguments are the following:
3738
-h | --help Print this message and exit
3839
-n | --noop Just print the commands but don't make changes.
39-
40+
-s | --next-steps At the end of running this script to create a new repo,
41+
some "next steps" are printed. If you want to see them again,
42+
use this flag to print them.
4043
These arguments are required, but they can appear in any order. See the example below:
4144
4245
--repo-name | -r name The name of gitHub repo. See example below.
@@ -64,12 +67,52 @@ NOTE: The title and work group strings need to be quoted if they contain spaces!
6467
EOF
6568
}
6669

70+
next_steps() {
71+
cat << EOF
72+
73+
Next Steps:
74+
75+
1. Go to https://github.com/The-AI-Alliance and create a _public_ repo named with
76+
the same name you used. If you don't have permissions, ask Dean Wampler,
77+
Adam Pingel, Joe Olson, or Trevor Grant to do this.
78+
3. Follow the instructions given for adding a remote (upstream) location to your
79+
local repo. If someone else creates the repo for you, remind them to give you
80+
the instructions!
81+
4. Push your local content up to the remote repo!
82+
TIP: Make sure both the "main" and "latest" branches are pushed upstream.
83+
5. In GitHub, go to the repo Settings, "Pages" section (left-hand side) to set up
84+
GitHub Pages publishing. You want to select "docs" as the folder from which the
85+
site is published and "latest" as the branch. (There are detailed instructions
86+
in the "README.md" generated for your site, if needed.)
87+
88+
A simpler experience is just to use "main" as the publication branch, so every
89+
merge to "main" automatically publishes your updated content. If you really want
90+
to do this, ask Dean Wampler for help.
91+
92+
Next, replace the placeholder text and "*.markdown" files with your content, e.g.,
93+
94+
1. Replace all occurrences of "TODO" with appropriate content.
95+
2. Rename or delete the "second_page.markdown". Copy it to add more top-level pages,
96+
but change the "nav_order" field!
97+
3. Use the "nested" directory content as an example of nesting content or delete it
98+
if you don't need it.
99+
4. Make any changes you want to make in the "docs/_config.yml" file. (None required.)
100+
101+
See also the "README.md" that was created in your new repo for more tips and guidance
102+
on development tasks.
103+
104+
If you want to see these instructions again, run the following command:
105+
106+
$script --next-steps
107+
EOF
108+
}
109+
67110
error() {
68111
for arg in "$@"
69112
do
70113
echo "ERROR ($script): $arg"
71114
done
72-
help
115+
echo "ERROR: Try: $script --help"
73116
exit 1
74117
}
75118

@@ -90,6 +133,10 @@ do
90133
-n|--n*)
91134
NOOP=echo
92135
;;
136+
-s|--next-steps)
137+
next_steps
138+
exit 0
139+
;;
93140
--repo-name|-r)
94141
shift
95142
repo_name="$1"
@@ -151,22 +198,23 @@ info " Title: $microsite_title"
151198
info " Work group: $work_group"
152199

153200
upstream_repo="microsite-template"
154-
targz=microsite-template.tar.gz
201+
targz="$upstream_repo-$$.tar.gz"
202+
untardir="The-AI-Alliance-$upstream_repo"
155203
info "Downloading $targz..."
204+
156205
if [[ -z $NOOP ]]
157206
then
158207
curl -L https://api.github.com/repos/The-AI-Alliance/$upstream_repo/tarball > $targz
159208
else
160209
$NOOP "curl -L https://api.github.com/repos/The-AI-Alliance/$upstream_repo/tarball > $targz"
161210
fi
162211
$NOOP tar xzf $targz
163-
$NOOP rm $targz
212+
#$NOOP rm $targz
164213

165-
# The directory should only
166-
for dir in *${upstream_repo}*
214+
for d in ${untardir}*
167215
do
168-
info "Renaming $dir to $repo_name:"
169-
$NOOP mv $dir $repo_name
216+
info "Renaming downloaded directory "$d" to $repo_name:"
217+
$NOOP mv "$d" $repo_name
170218
done
171219

172220
info "Removing this script file, $script and README.md from your copy of the repo, and moving README-template.md to README.md!"
@@ -228,51 +276,5 @@ info "Create a 'latest' branch from which the pages will be published:"
228276
$NOOP git checkout -b latest
229277
$NOOP git commit -m 'publication branch: latest' .
230278

231-
info <<EOF
232-
233-
Done! The current working directory is $PWD.
234-
235-
Next Steps:
236-
237-
1. Go to https://github.com/The-AI-Alliance and create a _public_ repo named with the same name you used.
238-
If you don't have permissions, ask Dean Wampler, Adam Pingel, Joe Olson, or Trevor Grant to do this.
239-
3. Follow the instructions given for adding a remote (upstream) location to your local repo.
240-
If someone else creates the repo for you, remind them to give you the instructions!
241-
4. Push your local content up to the remote repo! TIP: Make sure both the "main" and "latest" branches are
242-
pushed upstream.
243-
5. In GitHub, go to the repo Settings, "Pages" section (left-hand side) to set up GitHub Pages publishing.
244-
You want to select "docs" as the folder from which the site is published and "latest" as the branch.
245-
(There are more detail instructions in the "README.md" generated for your site, if needed.)
246-
247-
A simpler experience is just to use "main" as the publication branch, so every merge to "main"
248-
automatically publishes your updated content. If you really want to do this, ask Dean Wampler for help.
249-
250-
Next, replace the placeholder text and "*.markdown" files with your real content, e.g.,
251-
252-
1. Replace all occurrences of "TODO" with appropriate content.
253-
2. Rename or delete the "second_page.markdown". Copy it to add more top-level pages, but change the
254-
"nav_order" field!
255-
3. Use the "nested" directory content as an example of nesting content or delete it if you don't need it.
256-
4. Make any changes you want to make in the "docs/_config.yml" file. (None are required.)
257-
258-
See also the "README.md" that was created in your new repo for more tips and guidance on development tasks.
259-
260-
1. Go to https://github.com/The-AI-Alliance and create a repo named "$repo_name".
261-
If you don't have permissions, as Dean Wampler, Adam Pingel, Joe Olson, or Trevor Grant to do this.
262-
2. Follow the instructions given for adding a remote (upstream) location to your local repo.
263-
If someone else creates the repo for you, remind them to give you the instructions!
264-
3. Push your local content up to the remote repo!
265-
TIP: Make sure both the "main" and "latest" branches are pushed upstream.
266-
4. In GitHub, go to the repo Settings, "Pages" section (left-hand side) to set up GitHub Pages publishing.
267-
You want to select "docs" as the folder from which the site is published and "latest" as the branch!!
268-
A simpler experience is just to publish from the "main" branch, but ask Dean Wampler how to do that,
269-
if that's what you decide to do.
270-
271-
Next, replace the placeholder text and files with your real files, e.g.,
272-
273-
1. Replace all occurrences of "TODO" with appropriate content.
274-
2. Rename or delete the "second_page.markdown". Copy it to add more top-level pages, but change the "nav_order" field!
275-
3. Use the "nested" directory content as an example of nesting content or delete it if you don't need it.
276-
277-
See also the README.md that was created for more tips and guidance on development tasks.
278-
EOF
279+
info "Done! The current working directory is $PWD."
280+
next_steps

0 commit comments

Comments
 (0)