https://help.github.com/en/articles/virtual-environments-for-github-actions#default-environment-vari...
The GITHUB_REF var is currently returning value like "refs/pull/421/merge" which contains no mention of any branch name from which the PR was created. How can I achieve the same?
The pull request event contains the information you're looking for. If you're in a javascript action, context.payload.pull_request.head.ref will give you the branch name. (where context comes from const {context} = require('@actions/github')).
If you're in yaml, then I believe it would be github.payload.pull_request.head.ref (see https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions#github-context).
@jaredly Here's my problem, I am trying to use bundlesize package for my repo using github actions. The package uses another package called ci-env which reads branch name from process.env.GITHUB_REF here, which is wrong. So I just wanted to replace this env var value with the context value you suggested. But I see here that the GITHUB_ env vars can't be overridden. What should be done now?
You'll need to fork ci-env to allow the branch name to be overridden (using a different env vbl), I should think
I have raised a PR to fix this
https://github.com/siddharthkp/ci-env/pull/29/files
process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF && process.env.GITHUB_REF.split('/')[2]
should suffice, right?