[CI] add wait for /orig branch in mergeability check (#118576)

---

Test runs:
* [happy path](https://github.com/pytorch/pytorch/actions/runs/7702614677/job/20991275431?pr=118576) (this PR)
* [waiting for the hardcoded branch name](https://github.com/izaitsevfb/pr-head-test/actions/runs/7702386966/job/20990584514#step:3:33) in a separate repo (step succeeded after the branch was manually pushed)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/118576
Approved by: https://github.com/malfet, https://github.com/huydhn
This commit is contained in:
Ivan Zaitsev 2024-01-29 14:00:55 -08:00 committed by PyTorch MergeBot
parent a40be5f4dc
commit e3d7a19f73

View File

@ -20,6 +20,34 @@ jobs:
git config --global user.name "PyTorch MergeBot"
git fetch origin main:main
- name: Wait for orig branch
shell: bash
run: |
BRANCH="${{ github.base_ref }}"
echo "$BRANCH"
BRANCH="${BRANCH%/base}/orig"
echo "$BRANCH"
WAIT_SECONDS=300
END_WAIT=$((SECONDS+WAIT_SECONDS))
BRANCH_EXISTS=0
while [ $SECONDS -lt $END_WAIT ]; do
git fetch --prune origin "${BRANCH}" || true
if git rev-parse --verify "origin/${BRANCH}"; then
BRANCH_EXISTS=1
break
fi
echo "Waiting for branch ${BRANCH} to exist..."
sleep 30 # Wait for 30 seconds before retrying
done
if [ $BRANCH_EXISTS -eq 0 ]; then
echo "Branch ${BRANCH} not found after ${WAIT_SECONDS} seconds."
echo "Mergeability check failed for infrastructure reasons."
exit 1
fi
- name: Setup Python
uses: actions/setup-python@v4
with: