Skip to content

Instantly share code, notes, and snippets.

@ryanj
Created February 17, 2023 19:08
Show Gist options
  • Save ryanj/5a391fdc7f531f520d4b5524d51091d3 to your computer and use it in GitHub Desktop.
Save ryanj/5a391fdc7f531f520d4b5524d51091d3 to your computer and use it in GitHub Desktop.
install Calls to Action at the end of each track
#!/bin/bash
# Requirements: yq, bash
#set -euo pipefail
# Check for the yq command
if ! command -v yq &> /dev/null
then
echo "The yq command could not be found."
exit 1
fi
for track in $(ls -d instruqt-tracks/*/ | grep -v track-slugs.yml ); do
#yq '" - { slug: " + .slug + ", id: " + .id + " }"' ${track}track.yml >> track-slugs.yml
TITLE=$(yq .title ${track}track.yml)
#IMAGE=$(yq .virtualmachines[].image ${track}config.yml)
#SLUG=$(yq .slug ${track}track.yml)
#echo $SLUG
#echo "git mv $track instruqt-tracks/$SLUG"
ASSIGNMENTS=$(ls ${track}[0-1][0-9]-*/assignment.md 2>/dev/null)
COUNT_ASSIGNMENTS=$(ls ${track}[0-1][0-9]-*/assignment.md 2>/dev/null | wc -l)
if [ $COUNT_ASSIGNMENTS -eq 0 ] ; then
#echo "Zero Assignments Found; append to track.yml"
echo "$TITLE" includes $COUNT_ASSIGNMENTS challenges, update the track.yml...
UPDATE=$(ls ${track}track.yml)
else
echo "$TITLE" includes $COUNT_ASSIGNMENTS challenges, update the last one...
for ASSIGNMENT in $ASSIGNMENTS; do
UPDATE=$ASSIGNMENT
done
fi
echo $UPDATE
cat << EOF >> $UPDATE
# What's Next?
Congratulations on completing this lab. Keep learning about OpenShift:
* Visit the [Red Hat Developer learning page](https://developers.redhat.com/learn) for more labs and resources
* [Want to try a free, instant 30-day OpenShift cluster? Get started with the Developer Sandbox for Red Hat OpenShift](https://developers.redhat.com/developer-sandbox)
Don't forget to finish the lab and rate your experience on the next page. Thanks for playing!
EOF
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment