Is there an option in the experimental-deploy goal...
# general
m
Is there an option in the experimental-deploy goal to not build the docker image again? I want to separate my ci and cd stages - build the image and publish in the ci and deploy the image without building again
g
https://www.pantsbuild.org/dev/reference/goals/experimental-deploy#publish_dependencies is the only option I know of here, but it doesn't exactly match your ask. In general, if you've already built it once it should be cached and do nothing.
m
@gorgeous-winter-99296 its in different jobs in the CICD so there is no cache
g
Right. Can I assume you're then using a tag, potentially computed from the environment? What kind of thing are you deploying with experimental-deploy? Helm?
m
Tag for the docker image? Yep I’m creating a tag based on the branch name and the commit sha. And yes I’m using helm in the experimental-deploy
g
Ok. So one workaround - I imagine - would be to just not depend on the image. I imagine you have something like
values={"image": "my/docker:target"}
? Would a viable solution be to just depend on the remote tag directly?
You could feasibly use a macro to switch between the two variants depending on the environment.
m
Wow nice idea, I will try it thank you :)
@gorgeous-winter-99296 I tried your suggestion but I can’t see how can I pass the branch name and commit to the chart values?
g
If you use the BUILD file values you can use
env
to read values from the environment. I tend to wrap this up in a macro, f.ex.:
Copy code
def tag_from_branch():
    bk_branch = env("BUILDKITE_BRANCH")
    if bk_branch in ["main", None]:
        return "latest"

    out = [None] * len(bk_branch)
    for idx, c in enumerate(bk_branch):
        if "a" <= c <= "z" or "A" <= c <= "Z" or "0" <= c <= "9":
            out[idx] = c

        else:
            out[idx] = "-"

    return "".join(out)
And then I use this macro in my build file, in this case on a
tag
field like so:
tag=tag_from_branch(),
.