github
This Dagger module provides utilities for working with GitHub repositories,particularly for computing Docker image names from repository metadata.
Key Features:
- Compute Docker image names from repository metadata
- Strip common prefixes from repository names
- Normalize names to lowercase for registry compatibility
- Validate image name format against Docker requirements
Usage:
Compute image name from GitHub repository:
dagger call compute-image-name \
--repo-owner=broadsage \
--repo-name=docker-alpine
# Output: broadsage/alpine
Use in GitHub Actions workflows:
- name: Compute image name
id: image
uses: dagger/dagger-for-github@v6
with:
module: github.com/broadsage/dagger-modules/modules/github@main
args: compute-image-name --repo-owner=${{ github.repository_owner }} --repo-name=${{ github.event.repository.name }}
Installation
dagger install github.com/broadsage/dagger-modules/modules/github@0d23f76b089363c2bf5de43862ebfe71a69789e3Entrypoint
Return Type
Github ! Example
dagger -m github.com/broadsage/dagger-modules/modules/github@0d23f76b089363c2bf5de43862ebfe71a69789e3 call \
func (m *MyModule) Example() *dagger.Github {
return dag.
Github()
}@function
def example() -> dagger.Github:
return (
dag.github()
)@func()
example(): Github {
return dag
.github()
}Types
Github 🔗
GitHub utilities module for repository operations and image naming conventions.
computeImageName() 🔗
Compute Docker image name from GitHub repository details.
Helper function for GitHub Actions workflows to automatically compute image names from repository metadata following naming conventions.
Args: repo_owner: Repository owner/organization (e.g., “broadsage”). repo_name: Repository name (e.g., “docker-alpine”). strip_prefix: Prefix to strip from repo name (default: “docker-”). Set to empty string to keep full name.
Returns: Formatted image name in lowercase (e.g., “broadsage/alpine”).
Raises: ValueError: If repo_owner or repo_name is empty or invalid.
Example: # GitHub Actions usage: # image_name = compute_image_name( # repo_owner=”\({{ github.repository_owner }}", # repo_name="\){{ github.event.repository.name }}” # )
# Examples:
# compute_image_name("broadsage", "docker-alpine") -> "broadsage/alpine"
# compute_image_name("BroadSage", "Docker-Redis") -> "broadsage/redis"
# compute_image_name("myorg", "myapp", "") -> "myorg/myapp"
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| repoOwner | String ! | - | No description provided |
| repoName | String ! | - | No description provided |
| stripPrefix | String ! | "docker-" | No description provided |
Example
dagger -m github.com/broadsage/dagger-modules/modules/github@0d23f76b089363c2bf5de43862ebfe71a69789e3 call \
compute-image-name --repo-owner string --repo-name string --strip-prefix stringfunc (m *MyModule) Example(ctx context.Context, repoOwner string, repoName string, stripPrefix string) string {
return dag.
Github().
ComputeImageName(ctx, repoOwner, repoName, stripPrefix)
}@function
async def example(repo_owner: str, repo_name: str, strip_prefix: str) -> str:
return await (
dag.github()
.compute_image_name(repo_owner, repo_name, strip_prefix)
)@func()
async example(repoOwner: string, repoName: string, stripPrefix: string): Promise<string> {
return dag
.github()
.computeImageName(repoOwner, repoName, stripPrefix)
}