~sircmpwn/sr.ht-discuss

1

builds: information about which branch is being built

Details
Message ID
<CAOnw6Y5h73x2u50duh+siRSm_amPL-AP-GUbMTrtKStqjACt9w@mail.gmail.com>
DKIM signature
missing
Download raw message
Hello,

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
Details
Message ID
<e79da74f-e7cb-42bc-9b6a-f1175d33c260@www.fastmail.com>
In-Reply-To
<CAOnw6Y5h73x2u50duh+siRSm_amPL-AP-GUbMTrtKStqjACt9w@mail.gmail.com> (view parent)
DKIM signature
missing
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
    else
        # Do not deploy
    fi
Reply to thread Export thread (mbox)