2015-05-05 16:06:04 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
cd "$(dirname "$0")" # Go to the script's directory
|
|
|
|
|
|
|
|
EVERY_REPO() {
|
2017-11-13 16:13:03 +00:00
|
|
|
# The block contents come in through standard input. Capture it here.
|
|
|
|
content=$(cat)
|
|
|
|
|
2015-05-05 16:06:04 +00:00
|
|
|
echo "# Starting EVERY_REPO"
|
|
|
|
|
|
|
|
# Get list of repos
|
|
|
|
for REPO in "${REPOS[@]}"; do
|
|
|
|
echo "## Looping one time for repo: $REPO"
|
|
|
|
|
|
|
|
# String replace REPO_ with the name
|
|
|
|
# This changes everything in the content block of the template.
|
|
|
|
# It rewrites {{__REPO__.name}} into {{resque.name}}, for instance.
|
|
|
|
# You can prefix your environment variables and do other things as well.
|
|
|
|
|
2017-11-13 16:13:03 +00:00
|
|
|
echo "$content" | sed "s/__REPO__/${REPO}/"
|
2015-05-05 16:06:04 +00:00
|
|
|
|
|
|
|
echo "## Looped one time for repo: $REPO"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "# Finished EVERY_REPO"
|
|
|
|
}
|
|
|
|
|
|
|
|
REPOS=(resque hub rip)
|
|
|
|
|
|
|
|
declare -A resque hub rip
|
|
|
|
resque=([name]=Resque [url]=http://example.com/resque)
|
|
|
|
hub=([name]=Hub [url]=http://example.com/hub)
|
|
|
|
rip=([name]=Rip [url]=http://example.com/rip)
|
2015-08-27 14:44:04 +00:00
|
|
|
. ../mo
|
|
|
|
cat <<EOF | mo
|
2015-05-05 16:06:04 +00:00
|
|
|
{{#EVERY_REPO}}
|
|
|
|
The repo is __REPO__
|
|
|
|
Name: {{__REPO__.name}}
|
|
|
|
URL: {{__REPO__.url}}
|
|
|
|
{{/EVERY_REPO}}
|
|
|
|
|
|
|
|
EOF
|