-
Notifications
You must be signed in to change notification settings - Fork 60.2k
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
GITHUB_REF and GITHUB_REF_NAME examples in Actions docs unclear #15319
Comments
Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines. |
@oofnikj Thanks so much for opening an issue! I'll triage this for the team to take a look 👀 |
Thanks for opening this issue! You proposal to add/clarify this information sounds good. You or anyone else is welcome to open a PR to address this. (Note that this was partially addressed in #15304) |
This comment was marked as spam.
This comment was marked as spam.
Why should |
It would certainly be more helpful for our use case to have a simpler way to get the branch name regardless of context. Here is the snippet of Python code we are using to get the branch name now. |
I think this has been covered and updated in a previous PR. I'm going to go ahead and close this now 💛 |
@cmwilson21 in what PR? |
In this action https://github.com/rlespinasse/github-slug-action, the behavior, described by @wickkidd, is possible with - name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- run:|
echo "$GITHUB_REF_NAME will serve the internal behavior of GitHub Action"
echo "${{ env.GITHUB_REF_NAME }} will serve the behavior of the GitHub Slug action"
shell: bash |
👋 Hey folks! Thanks for all the great feedback in this issue. We had this as an open issue for anyone to work on, but after reviewing it, we are going to remove it from the Thanks again for all your input! 💖 |
github/docs#15319 Signed-off-by: Filip Dobrovolný <dobrovolny.filip@gmail.com>
github/docs#15319 Signed-off-by: Filip Dobrovolny <dobrovolny.filip@gmail.com>
* Update build_and_deploy.yml Try to fix broken builds. Signed-off-by: Filip Dobrovolný <dobrovolny.filip@gmail.com> * Fix build_and_deploy.yml github/docs#15319 Signed-off-by: Filip Dobrovolny <dobrovolny.filip@gmail.com> --------- Signed-off-by: Filip Dobrovolný <dobrovolny.filip@gmail.com> Signed-off-by: Filip Dobrovolny <dobrovolny.filip@gmail.com> Co-authored-by: Jan Schoone <6106846+jschoone@users.noreply.github.com>
I have a step like this at the start of most workflows: - run: echo "REF=${{ github.event.pull_request && github.head_ref || github.ref_name }}" >> $GITHUB_ENV which lets me reference |
@ryan-williams Thanks for your example. I did not know there was ternary available in expression until I saw your example. Must have missed it in docs. Super handy to know about this. //EDIT Missed it probably because this was just one sentence with one example. There should be whole section just for ternary. I mostly used bash to make some stuff conditional and with ternary I don't have to do this any more. Such useful feature and it is not emphasized enough in docs... // EDIT 2 Just checked git blame for docs and ternary operator docs were added 2 months ago... So that is why I missed it. |
Does it mean you're on it, or that we're going to wait another year or two for this simple feature? By then, nearly everyone got a workaround in place... |
A stale label has been added to this issue because it has been open for 60 days with no activity. To keep this issue open, add a comment within 3 days. |
3 days pass quickly nowadays... |
A simple and generic way to get the current branch name is still required and would be much appreciated. |
I recently learned that even using some bash condition can fail to figure out the ref name for current workflow run. Idk how GitHub runners work but this workflow step fails randomly (like 10% of times). I have already sent an issue about this to GitHub support. I have a workflow that is run on
90% of times this works fine: but in 10% of cases it fails: Based on GitHub docs about
Also this randomness is not just happening inside one repository workflow runs. When it happens it happens for multiple repositories at similar time. Really weird stuff going on. |
If anyone is interested about my issue with getting current ref with
It seems for now this is low prio for them and as a workaround I should use
to get release ref without random problems. |
@piotrekkr Thanks for coming back and reporting the convo with support! 👍 |
Code of Conduct
What article on docs.github.com is affected?
https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
What part(s) of the article would you like to see updated?
GITHUB_REF
andGITHUB_REF_NAME
show example values ofrefs/heads/feature-branch-1
andfeature-branch-1
respectively. However this is inconsistent with the values populated in the case of a PR-triggered workflow.Given the description and example, one would expect to see the branch that triggered the workflow when running a PR-triggered workflow. Instead these variables are populated by values like
refs/pull/26/merge
and26/merge
respectively. The variable that contains the desired data in this case is actuallyGITHUB_HEAD_REF
.The documentation should be updated to more accurately describe the content of GitHub Actions predefined variables.
Additional information
No response
The text was updated successfully, but these errors were encountered: