builds: information about which branch is being built

Message ID
DKIM signature
Download raw message

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
for git.sr.ht.

I know I could parse this information from git log or git show-ref but
is there a recommended way to do it?

My use-case:
- 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
from master.

Thanks for help
Message ID
<CAOnw6Y5h73x2u50duh+siRSm_amPL-AP-GUbMTrtKStqjACt9w@mail.gmail.com> (view parent)
DKIM signature
Download raw message
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
        # Deploy
        # Do not deploy
Export thread (mbox)