-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix branch returning incorrect value for GitHub Actions #29
Conversation
https://help.github.com/en/articles/virtual-environments-for-github-actions#default-environment-variables |
@siddharthkp can we merge this? |
@mohsinulhaq I couldn't find |
@mohsinulhaq Thanks 👍 |
@kuldeepkeshwar can you also review this one: siddharthkp/bundlesize#349 |
@mohsinulhaq I am sorry I don't have complete context here('bundlesize'). @Haroenv maybe the right person to complete the review. PS still I will give it a try |
@kuldeepkeshwar can we have a new release with the fix? It's blocking our github actions pull request discovery. |
@@ -79,7 +79,8 @@ if (process.env.TRAVIS) { | |||
event = process.env.GITHUB_EVENT_NAME | |||
commit_message = '' | |||
pull_request_number = '' | |||
branch = process.env.GITHUB_REF | |||
// GITHUB_HEAD_REF for pull requests. For commits, GITHUB_REF is of the form refs/heads/master, for example | |||
branch = process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF && process.env.GITHUB_REF.split('/')[2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw, process.env.GITHUB_REF.split('/')[2]
will almost certainly break various things.
By default, @dependabot uses /
a lot in its branch names:
Dependabot generates a branch for each pull request. Each branch name includes
dependabot
, and the package manager and dependency that are updated. By default, these parts are separated by a/
symbol, for example:dependabot/npm_and_yarn/next_js/acorn-6.4.1
.
(And random people can use it as well, especially people in large organizations.)
I'm only mentioning this because my GitHub workflow broke when someone used /
and I didn't have the right branch flags...
Fixes #28
process.env.GITHUB_ACTIONS
is set totrue
, which is the true check for GitHub actions environment.For commits, I found no straightforward way to get the branch name.