Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created October 12, 2021 15:14
Show Gist options
  • Save KyMidd/080d466257b7e2b094ed4b816de0bc10 to your computer and use it in GitHub Desktop.
Save KyMidd/080d466257b7e2b094ed4b816de0bc10 to your computer and use it in GitHub Desktop.
# Attempt push, open PR
gitPushResults=
gitPushResults=$(git push origin $branch --force 2>&1 || true)
# Check if failed to push due to archived read-only
if echo "$gitPushResults" | grep -q "This repository was archived"; then
echo "This repository is archived, and is read-only, skipping"
# Cleanup
cd ../
rm -rf $repo
# Continue to next loop
continue
elif echo "$gitPushResults" | grep -q "already exists"; then
echo "Pull request already exists with this name, skipping"
# Cleanup
cd ../
rm -rf $repo
# Continue to next loop
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment