Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created October 12, 2021 14:59
Show Gist options
  • Save KyMidd/58fc9d3aec246d0768c3bf9da79a1241 to your computer and use it in GitHub Desktop.
Save KyMidd/58fc9d3aec246d0768c3bf9da79a1241 to your computer and use it in GitHub Desktop.
# Attempt git push, check for archived to safely catch
gitPushResults=
gitPushResults=$(git push --force --set-upstream origin main 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
fi
else
# Repo cloned successfully
cd $repo
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment