Skip to content

Instantly share code, notes, and snippets.

@briandfoy
Created August 26, 2022 12:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandfoy/6dc60a39ae4d522ef53ff900d44c8269 to your computer and use it in GitHub Desktop.
Save briandfoy/6dc60a39ae4d522ef53ff900d44c8269 to your computer and use it in GitHub Desktop.
Makin' some PRs. Hold my beer.
#!/bin/bash
# Don't judge me too harshly. This is a throwaway that I put
# together in 5 minutes to make a couple hundred pull requests
DEV=/Users/brian/Dev
target=.github/workflows/windows.yml
message="Update windows workflow"
echo MESSAGE $message
branch=windows-update
json=$(cat <<-END
{"title":"${message}","body":"","head":"$branch","base":"master"}
END
)
echo JSON "$json"
ls */.github/workflows/windows.yml | perl -lpe 's|/.*||' | while read -r line
do
echo '-----' $line '-----------------------------------'
cd $DEV/$line
echo -n 'Now in '
pwd
git checkout -b $branch
git checkout $branch
touch .github/workflows/release.yml
bmt update_workflows
git add $target
git commit -m "$message" $target
git push origin $branch 2>&1
curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token $BMT_GITHUB_TOKEN" https://api.github.com/repos/briandfoy/$line/pulls -d "$json" > /dev/null
pull_number=`curl -s -H 'Accept: application/vnd.github+json' -H 'Authorization: token $BMT_GITHUB_TOKEN' https://api.github.com/repos/briandfoy/$line/pulls | jq -r '.[0] | .number'`
sleep 5
echo "PULL NUMBER" ${pull_number}
curl -s -X PUT -H "Accept: application/vnd.github+json" -H "Authorization: token $BMT_GITHUB_TOKEN" https://api.github.com/repos/briandfoy/$line/pulls/${pull_number}/merge
sleep 5
git checkout master
git pull
git branch -D $branch
git push origin :$branch
sleep 2
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment