Skip to content

Commit

Permalink
feat: use custom Dagger function instead
Browse files Browse the repository at this point in the history
  • Loading branch information
LiquidLemon committed Apr 29, 2024
1 parent b69a9e5 commit 789086c
Show file tree
Hide file tree
Showing 8 changed files with 508 additions and 39 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/dagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ jobs:
- name: Call Dagger workflow
uses: dagger/dagger-for-github@v5
with:
verb: run
args: python helpers/build.py
verb: call
module: build-and-push
args: >
--git-ref=$GITHUB_REF
--git-commit=$GITHUB_SHA
--registry=ghcr.io
--image-name=whohacks
--registry-user=$GITHUB_ACTOR
--registry-token=env:GITHUB_TOKEN
6 changes: 6 additions & 0 deletions dagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "whohacks",
"sdk": "python",
"source": "dagger",
"engineVersion": "v0.11.2"
}
1 change: 1 addition & 0 deletions dagger/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/sdk/** linguist-generated
1 change: 1 addition & 0 deletions dagger/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/sdk
9 changes: 9 additions & 0 deletions dagger/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[project]
name = "main"
version = "0.0.0"
dependencies = []

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

454 changes: 454 additions & 0 deletions dagger/requirements.lock

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions dagger/src/main/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import dagger
from dagger import dag, function, object_type


@object_type
class Whohacks:
@function
async def build_and_push(
*,
git_ref: str,
git_commit: str,
registry: str,
image_name: str,
registry_user: str,
registry_token: dagger.Secret,
) -> str:
ctr = (
dag.container()
.build(dag.host().directory("."), dockerfile="docker/web/Dockerfile")
.with_registry_auth(registry, registry_user, registry_token)
)

full_name = f"{registry}/{image_name}"
await ctr.publish(f"{full_name}:dev-{git_commit}")

if git_ref == "refs/heads/master":
await ctr.publish(f"{full_name}:latest")
37 changes: 0 additions & 37 deletions helpers/build.py

This file was deleted.

0 comments on commit 789086c

Please sign in to comment.