Closed 13rac1 closed 3 years ago
This is a big problem for repos that don't have a master branch (e.g. because they use GitHub's new default of main
).
Maybe you could check whether GITHUB_BASE_REF is set and use that? According to the docs it's only set for forks but that doesn't really make sense to me, especially considering the corresponding context says that it's set for PRs.
I've solved this in our fork https://github.com/lumeohq/block-fixup-merge-action, although it requires users to (only) run the action for pull_request
events (which IMO makes a lot of sense, then there is no need for filtering out tag pushes). I'm not sure whether you're interested in still maintaining this action considering you didn't reply to my previous comment, but if you are and don't mind the change from push to pull_request events I can send a PR for this change.
Please submit a PR, I'd be happy to merge. Thank you
The script only compares current branch with master right now. It could check for closest branch https://stackoverflow.com/questions/3161204/how-to-find-the-nearest-parent-of-a-git-branch but that isn't always correct.
The best way is probably using the Github API https://developer.github.com/v3/repos/commits/#list-pull-requests-associated-with-commit