I want to be able to run an action manually and specify the commit I want to tag. By default, I want to provide heads/main in my repository which should map to whatever the head commit is. commit_sha is pretty good as an override when I have a commit, but if I want the branch ref, it won't work. The error I get when I provided main is something like:
❗ ::error::Invalid request.%0A%0AAt least 40 characters are required; only 4 were supplied.
Modifications
Similar to how many git porcelain commands accept any refs, including commit SHAs and branch refs, I wrote a validation method that will check that the commit SHA is valid, and resolve a branch ref to a SHA if it wasn't a valid SHA. This allows plumbing calls like octokit.git.createTag() to work because the object actually refers to a SHA in all these intended cases.
Test
Locally, I wrote a quick and dirty test to call this method with my own repository configuration and access token. main doesn't work, but heads/main works just fine. The test looks something like
Use case
I want to be able to run an action manually and specify the commit I want to tag. By default, I want to provide
heads/main
in my repository which should map to whatever the head commit is.commit_sha
is pretty good as an override when I have a commit, but if I want the branch ref, it won't work. The error I get when I providedmain
is something like:Modifications
Similar to how many git porcelain commands accept any refs, including commit SHAs and branch refs, I wrote a validation method that will check that the commit SHA is valid, and resolve a branch ref to a SHA if it wasn't a valid SHA. This allows plumbing calls like
octokit.git.createTag()
to work because the object actually refers to a SHA in all these intended cases.Test
Locally, I wrote a quick and dirty test to call this method with my own repository configuration and access token.
main
doesn't work, butheads/main
works just fine. The test looks something likeAlternatives
One can simply set GITHUB_REF so that it reflects the branch the user wants to be on, and hopefully encapsulates the commit as well.