Skip to content

Instantly share code, notes, and snippets.

@briandfoy
Created August 26, 2022 12:44
Show Gist options
  • Select an option

  • Save briandfoy/6dc60a39ae4d522ef53ff900d44c8269 to your computer and use it in GitHub Desktop.

Select an option

Save briandfoy/6dc60a39ae4d522ef53ff900d44c8269 to your computer and use it in GitHub Desktop.

Revisions

  1. briandfoy created this gist Aug 26, 2022.
    41 changes: 41 additions & 0 deletions mega_pr.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    #!/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