#!/bin/bash -l

set -o errexit
set -o nounset
set -o pipefail
set -x

rsync -a buildpack/ updated-buildpack/

pushd updated-buildpack/scripts
  git checkout master
  submodule_commit="$(git log --format=%B -n 1 HEAD | head -n 1)"
popd

pushd updated-buildpack
  git add .

  set +e
    git diff --cached --exit-code
    no_changes=$?
  set -e

  if [ $no_changes -ne 0 ]

  then
    git commit -m "$(cat <<-EOF
Update scripts submodule

- $submodule_commit
EOF
)"
  else
    echo "scripts are already up to date"
  fi
popd

#!/bin/bash -l

set -o errexit
set -o nounset
set -o pipefail
set -x

rsync -a buildpack/ updated-buildpack/

pushd updated-buildpack
  git submodule update --init --remote
popd

pushd updated-buildpack/scripts
  submodule_commit="$(git log --format=%B -n 1 HEAD | head -n 1)"
popd

pushd updated-buildpack
  git add .

  set +e
    git diff --cached --exit-code
    no_changes=$?
  set -e

  if [ $no_changes -ne 0 ]

  then
    git commit -m "$(cat <<-EOF
Update scripts submodule

- $submodule_commit
EOF
)"
  else
    echo "scripts are already up to date"
  fi
popd

Update update-cnb-scripts task to get latest submodule
Update update-cnb-scripts task to get latest submodule

Co-authored-by: Guillermo Kardolus <f995e5708409e0468f92322e706c77752cc6c0d4@pivotal.io>
