Created
March 26, 2021 18:54
-
-
Save pwtyler/326fb72dffd5de5692a4c66a858d875c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
PULL_REQUEST_ID=${1:-} | |
if [[ -z "${PULL_REQUEST_ID}" ]]; then | |
echo "usage: $0 PULL_REQUEST_ID" | |
exit 1 | |
fi | |
echo "Working on PR $PULL_REQUEST_ID" | |
GHUB_SSH_URL="[email protected]:pantheon-systems/WordPress.git" | |
PROJECT_NAME="pwordpress" | |
WORKDIR=/tmp/work/ | |
PROJECT_DIR="$WORKDIR/$PROJECT_NAME" | |
# Clone the project if necessary | |
mkdir -p "${WORKDIR}" | |
if [ ! -d "${PROJECT_DIR}" ] ; then | |
( | |
cd "${WORKDIR}" && git clone "${GHUB_SSH_URL}" "${PROJECT_NAME}" | |
) | |
fi | |
cd "${PROJECT_DIR}" | |
pwd | |
TEST_BRANCH_NAME="TEST-FORK-PR-$PULL_REQUEST_ID" | |
hub checkout "$(hub browse -u )/pull/$PULL_REQUEST_ID" "${TEST_BRANCH_NAME}" | |
git push origin "${TEST_BRANCH_NAME}" | |
hub browse -- tree/"${TEST_BRANCH_NAME}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment