vsoch / pull-request-action

open a pull request when a branch is pushed or updated

Home Page:https://github.com/marketplace/actions/pull-request-action

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use repo default branch instead of hard-coded "master"

dannysauer opened this issue · comments

pull_request_branch = os.environ.get("PULL_REQUEST_BRANCH", "master")

It probably makes sense to use the relevant API call to fetch the default branch of a repo instead of hard-coding in "master" here. Github made the change last year, and the way to get the value in a shell is

curl -L -H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
            https://api.github.com/repos/${owner}/${repo} \
            | jq .default_branch

That should be pretty straightforward to translate into Python. I'll open a PR when I find a few spare minutes if no one else does it first.

That's a great idea! Yes, would gladly accept a PR for this update. Thank you @dannysauer !