Skip to content

Instantly share code, notes, and snippets.

@patleeman
Created October 10, 2019 14:57
Show Gist options
  • Save patleeman/2136bcf911a8c713c5946a29221b2fd5 to your computer and use it in GitHub Desktop.
Save patleeman/2136bcf911a8c713c5946a29221b2fd5 to your computer and use it in GitHub Desktop.
Example build script for project Meristem.
#!/bin/bash
# Set git fetch match pattern to fetch all branches.
# If this isn't set, running git fetch may not pull all the branches we need.
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git clone ${REPO_URL} tmp/
cd tmp/
git fetch --all
# Stop the script if something breaks during checkout. i.e. SHA wasn't pushed to origin.
if ! git checkout ${baseline_branch}; then
exit 1
fi
cd ..
cp -r tmp/ build/
# jq is a json processing utility https://stedolan.github.io/jq/
for row in $(echo "${variations}" | jq -c '.[]'); do
name=$(echo ${row} | jq -r '.name')
sha=$(echo ${row} | jq -r '.sha')
cd tmp/
if ! git checkout ${sha}; then
exit 1
fi
cd ..
cp -r tmp/src/flows/baseline build/src/flows/${name}
done
cd build
npm ci
npm run build
cd ..
# Move the built assets into this repo's dist folder and clean up.
mv build/dist .
rm -rf build/
rm -rf tmp/
echo "Build complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment