Skip to content

Instantly share code, notes, and snippets.

@amacneil
Last active January 4, 2023 22:26
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amacneil/f14db753919e0af2d7d2f5a8da7fce65 to your computer and use it in GitHub Desktop.
Save amacneil/f14db753919e0af2d7d2f5a8da7fce65 to your computer and use it in GitHub Desktop.
#!/bin/bash
# if we are testing a PR, merge it with the latest master branch before testing
# this ensures that all tests pass with the latest changes in master.
set -eu -o pipefail
PR_NUMBER=${CI_PULL_REQUEST//*pull\//}
err=0
if [ -z "$PR_NUMBER" ]; then
exit
fi
(set -x && git pull --ff-only origin "refs/pull/$PR_NUMBER/merge") || err=$?
if [ "$err" -ne "0" ]; then
echo
echo -e "\033[0;31mERROR: Failed to merge your branch with the latest master."
echo -e "Please manually merge master into your branch, and push the changes to GitHub.\033[0m"
exit $err
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment