I'm in the process of transitioning to sr.ht and I have a question
about builds and git.sr.ht.
When I hosted my code on GitHub, GITHUB_REF env variable could be used
to identify what branch is being built. But I cannot find the similar
I know I could parse this information from git log or git show-ref but
is there a recommended way to do it?
- all my changes on master branch are automatically deployed somewhere
- when I'm creating a new branch, I want the deployment to be ignored
With the branch parse the info from git show-ref is tricky because if
the branch was just creating, the commit is basically the same one
Thanks for help
You could do something like this in your deploy script.
# We only want to deploy when on master. We cannot check if
# --abbrev-ref is master because the HEAD is detached.
if [ "$(git rev-parse master)" = "$(git rev-parse HEAD)" ]; then
# Do not deploy