Dagger
Search

dagger2gha

Daggerizing your CI makes your YAML configurations smaller, but they still exist,
and they're still a pain to maintain by hand.

This module aims to finish the job, by letting you generate your remaining
YAML configuration from a Dagger pipeline, written in your favorite language.
Example
no available example in current language
// Generate a simple configuration triggered by git push on main, and pull requests
// 1. Prints "hello, main!" on push to main
// 2. Prints "hello, pull request!" on new pull request
func (m *Examples) Dagger2Gha() *dagger.Directory {
	return dag.
		Dagger2Gha().
		OnPush("hello --name=main", dagger.Dagger2GhaOnPushOpts{
			Branches: []string{"main"},
			Module:   "github.com/shykes/hello",
		}).
		OnPullRequest("hello --name='pull request'", dagger.Dagger2GhaOnPullRequestOpts{
			Module: "github.com/shykes/hello",
		}).
		Config(dagger.Dagger2GhaConfigOpts{
			Prefix: "example-",
		})
}
no available example in current language
no available example in current language
Example (OnDispatch)
no available example in current language
// Generate a configuration with a "dispatch" workflow,
// that can be triggered manually, independently of any platform event.
func (m *Examples) Dagger2Gha_OnDispatch() *dagger.Directory {
	return dag.
		Dagger2Gha().
		OnDispatch("deploy-docs", dagger.Dagger2GhaOnDispatchOpts{
			Secrets: []string{"DOCS_SERVER_PASSWORD"},
		}).
		Config(dagger.Dagger2GhaConfigOpts{
			Prefix: "example-",
		})
}
no available example in current language
no available example in current language

Installation

dagger install github.com/shykes/dagger2gha@v0.5.0

Entrypoint

Return Type
Dagger2Gha !
Arguments
NameTypeDefault ValueDescription
noTracesBoolean -Disable sending traces to Dagger Cloud
publicTokenString -Public Dagger Cloud token, for open-source projects. DO NOT PASS YOUR PRIVATE DAGGER CLOUD TOKEN! This is for a special "public" token which can safely be shared publicly. To get one, contact support@dagger.io
daggerVersionString "latest"Dagger version to run in the Github Actions pipelines
stopEngineBoolean -Explicitly stop the Dagger Engine after completing the pipeline
asJsonBoolean -Encode all files as JSON (which is also valid YAML)
runnerString "ubuntu-latest"Configure a default runner for all workflows See https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/using-self-hosted-runners-in-a-workflow
Example
dagger -m github.com/shykes/dagger2gha@058e9d7db07be5ff13ab82bcc5cdddf1f9ea34bf call \
func (m *myModule) example() *Dagger2Gha  {
	return dag.
			Dagger2gha()
}
@function
def example() -> dag.Dagger2Gha:
	return (
		dag.dagger2gha()
	)
@func()
example(): Dagger2Gha {
	return dag
		.dagger2gha()
}

Types

Dagger2Gha 🔗

onPush() 🔗

Add a trigger to execute a Dagger pipeline on a git push

Return Type
Dagger2Gha !
Arguments
NameTypeDefault ValueDescription
commandString !-The Dagger command to execute Example 'build --source=.'
moduleString "."The Dagger module to load
secrets[String ! ] -Github secrets to inject into the pipeline environment. For each secret, an env variable with the same name is created. Example: ["PROD_DEPLOY_TOKEN", "PRIVATE_SSH_KEY"]
branches[String ! ] -Run only on push to specific branches
tags[String ! ] -Run only on push to specific branches
paths[String ! ] -Run only on push to specific paths
runnerString -Dispatch jobs to the given runner
Example
dagger -m github.com/shykes/dagger2gha@058e9d7db07be5ff13ab82bcc5cdddf1f9ea34bf call \
 on-push --command string
func (m *myModule) example(command string) *Dagger2Gha  {
	return dag.
			Dagger2gha().
			OnPush(command)
}
@function
def example(command: str) -> dag.Dagger2Gha:
	return (
		dag.dagger2gha()
		.on_push(command)
	)
@func()
example(command: string): Dagger2Gha {
	return dag
		.dagger2gha()
		.onPush(command)
}

onPullRequest() 🔗

Add a trigger to execute a Dagger pipeline on a pull request

Return Type
Dagger2Gha !
Arguments
NameTypeDefault ValueDescription
commandString !-The Dagger command to execute Example 'build --source=.'
moduleString "."Dagger module to load
secrets[String ! ] -Github secrets to inject into the pipeline environment. For each secret, an env variable with the same name is created. Example: ["PROD_DEPLOY_TOKEN", "PRIVATE_SSH_KEY"]
branches[String ! ] -Run only for pull requests that target specific branches
types[String ! ] -Run only for certain types of pull request events See https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request
runnerString -Dispatch jobs to the given runner
Example
dagger -m github.com/shykes/dagger2gha@058e9d7db07be5ff13ab82bcc5cdddf1f9ea34bf call \
 on-pull-request --command string
func (m *myModule) example(command string) *Dagger2Gha  {
	return dag.
			Dagger2gha().
			OnPullRequest(command)
}
@function
def example(command: str) -> dag.Dagger2Gha:
	return (
		dag.dagger2gha()
		.on_pull_request(command)
	)
@func()
example(command: string): Dagger2Gha {
	return dag
		.dagger2gha()
		.onPullRequest(command)
}

onDispatch() 🔗

Add a trigger to execute a Dagger pipeline on a workflow dispatch event

Return Type
Dagger2Gha !
Arguments
NameTypeDefault ValueDescription
commandString !-The Dagger command to execute Example 'build --source=.'
moduleString "."Dagger module to load
secrets[String ! ] -Github secrets to inject into the pipeline environment. For each secret, an env variable with the same name is created. Example: ["PROD_DEPLOY_TOKEN", "PRIVATE_SSH_KEY"]
runnerString -Dispatch jobs to the given runner
Example
dagger -m github.com/shykes/dagger2gha@058e9d7db07be5ff13ab82bcc5cdddf1f9ea34bf call \
 on-dispatch --command string
func (m *myModule) example(command string) *Dagger2Gha  {
	return dag.
			Dagger2gha().
			OnDispatch(command)
}
@function
def example(command: str) -> dag.Dagger2Gha:
	return (
		dag.dagger2gha()
		.on_dispatch(command)
	)
@func()
example(command: string): Dagger2Gha {
	return dag
		.dagger2gha()
		.onDispatch(command)
}

config() 🔗

Generate a github config directory, usable as an overlay on the repository root

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
prefixString -Prefix to use for generated workflow filenames
Example
dagger -m github.com/shykes/dagger2gha@058e9d7db07be5ff13ab82bcc5cdddf1f9ea34bf call \
 config
func (m *myModule) example() *Directory  {
	return dag.
			Dagger2gha().
			Config()
}
@function
def example() -> dagger.Directory:
	return (
		dag.dagger2gha()
		.config()
	)
@func()
example(): Directory {
	return dag
		.dagger2gha()
		.config()
}