another attempt
This commit is contained in:
@@ -15,10 +15,11 @@ type KforgeConfig struct {
|
||||
Preview PreviewConfig `yaml:"preview,omitempty"`
|
||||
Environments map[string]EnvironmentConfig `yaml:"environments"`
|
||||
|
||||
// ActionRef is the Gitea Actions reference to this kforge installation
|
||||
// (e.g. "gitea.example.com/infra/kforge@main"). When set, kforge gitea-actions
|
||||
// and kforge gitea-preview generate workflows that call kforge as a reusable
|
||||
// action step instead of installing and running kforge inline.
|
||||
// ActionRef is the Docker image reference for the pre-built kforge action
|
||||
// (e.g. "registry.example.com/infra/kforge:latest"). When set, kforge
|
||||
// gitea-actions and kforge gitea-preview generate `uses: docker://<ref>`
|
||||
// steps instead of installing and running kforge inline. The kforge repo
|
||||
// must publish this image on each release.
|
||||
ActionRef string `yaml:"action_ref,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -104,8 +104,11 @@ func writeDeployJobs(b *strings.Builder, cfg *config.KforgeConfig, opts GiteaAct
|
||||
}
|
||||
}
|
||||
|
||||
// writeActionDeploySteps emits one `uses: action_ref` step per environment.
|
||||
// writeActionDeploySteps emits one `uses: docker://image` step per environment.
|
||||
// The docker:// prefix tells act/Gitea Actions to pull the image from the OCI
|
||||
// registry directly, bypassing GitHub/Gitea source resolution.
|
||||
func writeActionDeploySteps(b *strings.Builder, cfg *config.KforgeConfig, opts GiteaActionsOptions) {
|
||||
image := "docker://" + cfg.ActionRef
|
||||
for _, envKey := range opts.Environments {
|
||||
env, err := config.ResolveEnvironment(cfg, envKey)
|
||||
if err != nil {
|
||||
@@ -113,7 +116,7 @@ func writeActionDeploySteps(b *strings.Builder, cfg *config.KforgeConfig, opts G
|
||||
}
|
||||
label := strings.Title(envKey) //nolint:staticcheck
|
||||
writeStep(b, fmt.Sprintf("Deploy (%s)", label), map[string]any{
|
||||
"uses": cfg.ActionRef,
|
||||
"uses": image,
|
||||
"with": map[string]any{
|
||||
"command": "deploy",
|
||||
"env": envKey,
|
||||
@@ -274,12 +277,13 @@ func GeneratePreviewActions(cfg *config.KforgeConfig) (string, error) {
|
||||
})
|
||||
|
||||
if cfg.ActionRef != "" {
|
||||
image := "docker://" + cfg.ActionRef
|
||||
writeStep(&b, "Deploy preview", map[string]any{
|
||||
"if": "${{ github.event.action != 'closed' }}",
|
||||
"uses": cfg.ActionRef,
|
||||
"uses": image,
|
||||
"with": map[string]any{
|
||||
"command": "preview-up",
|
||||
"pr_number": "${{ github.event.number }}",
|
||||
"command": "preview-up",
|
||||
"pr_number": "${{ github.event.number }}",
|
||||
"namespace_prefix": nsPrefix,
|
||||
},
|
||||
"env": actionEnv(),
|
||||
@@ -287,7 +291,7 @@ func GeneratePreviewActions(cfg *config.KforgeConfig) (string, error) {
|
||||
|
||||
writeStep(&b, "Destroy preview", map[string]any{
|
||||
"if": "${{ github.event.action == 'closed' }}",
|
||||
"uses": cfg.ActionRef,
|
||||
"uses": image,
|
||||
"with": map[string]any{
|
||||
"command": "preview-down",
|
||||
"pr_number": "${{ github.event.number }}",
|
||||
|
||||
Reference in New Issue
Block a user