gha
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 (GithubContext)
no available example in current language// Access github context information magically injected as env variables
func (m *Examples) Gha_GithubContext() *dagger.Directory {
	return dag.
		Gha().
		OnDispatch(
			"git --url=https://github.com/$GITHUB_REPOSITORY branch --name=$GITHUB_REF tree glob --pattern=*",
			dagger.GhaOnDispatchOpts{
				Module: "github.com/shykes/core",
			}).
		Config()
}no available example in current languageno available example in current languageExample (Secrets)
no available example in current language// Access Github secrets
func (m *Examples) Gha_Secrets() *dagger.Directory {
	return dag.
		Gha().
		OnDispatch("deploy-docs", dagger.GhaOnDispatchOpts{
			Secrets: []string{"DOCS_SERVER_PASSWORD"},
		}).
		Config()
}no available example in current languageno available example in current languageInstallation
dagger install github.com/shykes/gha@v0.6.0Entrypoint
Return Type
Gha !Arguments
| Name | Type | Default Value | Description | 
|---|---|---|---|
| noTraces | Boolean | - | Disable sending traces to Dagger Cloud | 
| publicToken | String | - | 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 | 
| daggerVersion | String | "latest" | Dagger version to run in the Github Actions pipelines | 
| stopEngine | Boolean | - | Explicitly stop the Dagger Engine after completing the pipeline | 
| asJson | Boolean | - | Encode all files as JSON (which is also valid YAML) | 
| runner | String | "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/gha@584a9b4ba95c3fe1bd1378edcd3106dfa115a5cb call \
func (m *MyModule) Example() *dagger.Gha  {
	return dag.
			Gha()
}@function
def example() -> dagger.Gha:
	return (
		dag.gha()
	)@func()
example(): Gha {
	return dag
		.gha()
}Types
Gha 🔗
onPush() 🔗
Add a trigger to execute a Dagger pipeline on a git push
Return Type
Gha !Arguments
| Name | Type | Default Value | Description | 
|---|---|---|---|
| command | String ! | - | The Dagger command to execute Example 'build --source=.' | 
| module | String | "." | 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 | 
| runner | String | - | Dispatch jobs to the given runner | 
Example
no available example in current language// Generate a simple configuration triggered by git push on main
func (m *Examples) GhaOnPush() *dagger.Directory {
	return dag.
		Gha().
		OnPush("hello --name=main", dagger.GhaOnPushOpts{
			Branches: []string{"main"},
			Module:   "github.com/shykes/hello",
		}).
		Config()
}no available example in current languageno available example in current languageonPullRequest() 🔗
Add a trigger to execute a Dagger pipeline on a pull request
Return Type
Gha !Arguments
| Name | Type | Default Value | Description | 
|---|---|---|---|
| command | String ! | - | The Dagger command to execute Example 'build --source=.' | 
| module | String | "." | 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 | 
| runner | String | - | Dispatch jobs to the given runner | 
Example
no available example in current language// Generate a simple configuration triggered by a pull request
func (m *Examples) GhaOnPullRequest() *dagger.Directory {
	return dag.
		Gha().
		OnPullRequest("hello --name='pull request'", dagger.GhaOnPullRequestOpts{
			Module: "github.com/shykes/hello",
		}).
		Config()
}no available example in current languageno available example in current languageonDispatch() 🔗
Add a trigger to execute a Dagger pipeline on a workflow dispatch event
Return Type
Gha !Arguments
| Name | Type | Default Value | Description | 
|---|---|---|---|
| command | String ! | - | The Dagger command to execute Example 'build --source=.' | 
| module | String | "." | 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"] | 
| runner | String | - | Dispatch jobs to the given runner | 
Example
dagger -m github.com/shykes/gha@584a9b4ba95c3fe1bd1378edcd3106dfa115a5cb call \
 on-dispatch --command stringfunc (m *MyModule) Example(command string) *dagger.Gha  {
	return dag.
			Gha().
			OnDispatch(command)
}@function
def example(command: str) -> dagger.Gha:
	return (
		dag.gha()
		.on_dispatch(command)
	)@func()
example(command: string): Gha {
	return dag
		.gha()
		.onDispatch(command)
}config() 🔗
Generate a github config directory, usable as an overlay on the repository root
Return Type
Directory !Arguments
| Name | Type | Default Value | Description | 
|---|---|---|---|
| prefix | String | - | Prefix to use for generated workflow filenames | 
Example
dagger -m github.com/shykes/gha@584a9b4ba95c3fe1bd1378edcd3106dfa115a5cb call \
 configfunc (m *MyModule) Example() *dagger.Directory  {
	return dag.
			Gha().
			Config()
}@function
def example() -> dagger.Directory:
	return (
		dag.gha()
		.config()
	)@func()
example(): Directory {
	return dag
		.gha()
		.config()
}