~sircmpwn/sr.ht-dev

1

On exposing the pushed git branch/ref in the build environment

Daniel Gröber
Details
Message ID
<20210409032835.mtuslekupf5ltuph@darkboxed.org>
DKIM signature
missing
Download raw message
Hi,

currently sr.ht's git service doesn't expose the pushed git ref in builds
submitted to builds.sr.ht, making nasty hacks such the ref-parse thing in
[#270] necessary.

[#270]: https://todo.sr.ht/~sircmpwn/builds.sr.ht/170

From looking at the source for the dispatch service which does already set
set GITHUB_REF evvar for builds triggered via GH it seems the way to do
this is to just set the env vars in the manifest 'environment' dict before
submitting the build.

I would propose to set a GIT_REF variable in SubmitBuild() from
git.sr.ht/gitsrht-update-hook/submitter.go. We have easy access to the name
of the pushed ref coming from the postUpdate() function by adding a new
field to GitBuildSubmitter.

Does that seem reasonable?

I do wonder if care should be given to not breaking manifests that might
already set GIT_REF? Maybe a less generic name should be used or perhaps
only set the env var if it's not already there?

--Daniel
Details
Message ID
<CAJ5ZR0CMHF4.OSY49NVJSHXN@taiga>
In-Reply-To
<20210409032835.mtuslekupf5ltuph@darkboxed.org> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
I would be open to this patch.
Reply to thread Export thread (mbox)