Skip to content

Instantly share code, notes, and snippets.

@geerlingguy
Created September 25, 2016 20:49
Show Gist options
  • Select an option

  • Save geerlingguy/8bfc668852f44525a01235c8acafc948 to your computer and use it in GitHub Desktop.

Select an option

Save geerlingguy/8bfc668852f44525a01235c8acafc948 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Add a commit and push to origin for each 'geerlingguy.*'' Ansible role.
message="Remove sudo requirement from Travis build."
# Loop through all directories starting with "geerlingguy".
for dir in ./geerlingguy*/
do
# cd into role directory.
cd "$dir"
# Check if there's a change in the work tree.
if ! git diff --no-ext-diff --quiet --exit-code; then
echo "Change detected in $(basename $(pwd)). Committing and pushing changes."
git commit -a -m "$message" && git push
else
echo "Skipping $(basename $(pwd)) (no changes detected)."
fi
# cd back to parent directory.
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment