Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get hash step #12

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions transpire/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from types import ModuleType
from typing import Any, Callable, Iterable, List, Protocol, TypeVar

from hera import Env, SecretVolume, Task, Volume, Workflow
from hera import Env, Parameter, SecretVolume, Task, ValueFrom, Volume, Workflow
from kubernetes import client
from pydantic import BaseModel, Field

Expand Down Expand Up @@ -174,6 +174,14 @@ def workflow(self) -> Workflow:
working_dir="/build/build",
)

get_hash = Task(
"hash",
image="alpine/git:2.36.3",
args=["rev-parse", "HEAD"],
volumes=[volume],
working_dir="/build/build",
)

build = [
Task(
"build",
Expand All @@ -195,8 +203,12 @@ def workflow(self) -> Workflow:
"--local",
f"dockerfile={image.resolved_path}",
"--output",
# TODO: Get the git hash
f"type=image,name=harbor.ocf.berkeley.edu/ocf/{self.name}/{image.name}:latest,push=true",
(
"type=image,"
f"name=harbor.ocf.berkeley.edu/ocf/{self.name}/{image.name}:latest,"
f"name=harbor.ocf.berkeley.edu/ocf/{self.name}/{image.name}:{{{{tasks.hash.outputs.result}}}},"
"push=true"
),
],
volumes=[
volume,
Expand All @@ -219,6 +231,6 @@ def workflow(self) -> Workflow:
# invokes `Task.__rshift__`, which returns the RHS (`clone`), which is a
# `Task`. If `clone` ever becomes a list, this breaks (since there is no
# way for Hera to override `list >> list`).
self.pipeline() >> clone >> build # type: ignore
self.pipeline() >> clone >> get_hash >> build # type: ignore

return w