docs
docs copied to clipboard
The github.ref does not contain fully-formed ref of the branch
Code of Conduct
- [X] I have read and agree to the GitHub Docs project's Code of Conduct
What article on docs.github.com is affected?
https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
What part(s) of the article would you like to see updated?
The workflow run on my GitHub repo indicates that github.ref contains destination branch when PR is closed, and not refs/pull/<pr_number>/merge
Note that:
- Workflow file says
BRANCH=${{ github.ref }} - Workflow run prints
BRANCH=main
Either the documentation needs to be updated to use the following solution instead:
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
Or the backend code needs to be fixed to provide branch name in github.ref
Additional information
No response
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.
@trivikr Thanks so much for opening an issue! I'll triage this for the team to take a look :eyes:
Thanks @cmwilson21
It would be awesome if the bug in github.ref itself is fixed.
If that happens, the documentation is not required to be updated.
As per the documentation, the github.ref for pull_request should contain PR merge branch refs/pull/:prNumber/merge, but my tests shows main for closed activity.
@trivikr Thanks for this additional info ✨
Just a heads up, several members of our team are out for the holidays. Someone will have eyes on this soon, until then, we appreciate your patience 💖
Sure. I'm not blocked, as I used github.event.pull_request.number to compute branch name. There is a workaround.
This issue is created to either fix the issue in backend (recommended), or update the docs.
Hey @trivikr, thank you for opening this! I've reached out to a subject matter expert about this, and will keep you updated with what our next steps will be. 🚀
Thanks for opening an issue! We've triaged this issue for technical review by a subject matter expert :eyes:
Hey @trivikr 👋
After talking with a subject matter expert, we've determined the best way to resolve this would be to update the example code in the doc you linked to use github.head_ref instead of github.ref. This will give you the source branch instead of the merge branch, which is where you'd want to delete the caches from when you are using this workflow.
So if we change:
REPO=${{ github.repository }}
BRANCH=${{ github.ref }}
to
REPO=${{ github.repository }}
BRANCH=${{ github.head_ref }}
the workflow should do what you want it to do. You can find the supporting documentation for the github context here: https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
Thank you for sharing this issue with us, and you or anyone else is welcome to open a PR to apply these changes! 🚀
we've determined the best way to resolve this would be to update the example code in the doc you linked to use
github.head_refinstead ofgithub.ref
Using BRANCH=${{ github.head_ref }} does not work for my use case, as the value is source branch use-head-ref-branch-cache-cleanup and not merge branch refs/pull/362/merge.
Details in Pull Request: https://github.com/awslabs/aws-sdk-js-codemod/pull/362#issuecomment-1400882170
This will give you the source branch instead of the merge branch, which is where you'd want to delete the caches from when you are using this workflow.
I don't think works as caches are tied to merge branch as per documentation. https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
Hey @trivikr, I sent your question to our subject matter expert, and they are taking a look to get a better understanding of this. I do see what you are saying about how caches created on pull requests are linked to the merge ref instead of the source branch. I will update you when I have more information!
Thanks for opening an issue! We've triaged this issue for technical review by a subject matter expert :eyes:
در تاریخ چهارشنبه ۲۵ ژانویه ۲۰۲۳، ۱:۵۲ ق.ظ Siara @.***> نوشت:
Hey @trivikr https://github.com/trivikr, I sent your question to our subject matter expert, and they are taking a look to get a better understanding of this. I do see what you are saying about how caches created on pull requests are linked to the merge ref instead of the source branch. I will update you when I have more information!
— Reply to this email directly, view it on GitHub https://github.com/github/docs/issues/22727#issuecomment-1402767288, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5EC2T7NLXW2FZKF7FC7SODWUBI37ANCNFSM6AAAAAATAL4ZSY . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hey @trivikr, I heard back from our subject matter expert and your proposed solution to update:
BRANCH=${{ github.ref }} to BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
in the example is a great one. You or anyone else is welcome to pick up this issue and implement that change. 💛 Thank you again for finding this error and working through it with us!
Thanks! I've posted a PR to update cache cleanup example at https://github.com/github/docs/pull/23612
Issue reported once more in:
- #23600
Thanks for working out the fix!