Something went wrong. Try again.
Something went wrong. Try again.
2.0 kB · 72 lines
Go
at master
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273/*Copyright © 2026 Karn Wong <karn@karnwong.me>*/package cmd
import ( "path/filepath"
"github.com/kahnwong/config-init/template" "github.com/spf13/cobra")
var githubActionsOptions = []string{ "android-test", "cloudflare-pages", "docker-bake", "docker-build", "github-pages", "go-test", "goreleaser", "nix", "node-test", "osv-scanner", "pre-commit", "python-test", "rust-test", "tangled-mirror",}
var githubActionsMapping = map[string][][2]string{ "android-test": {{"android-test.yaml", "android-test.yaml"}}, "cloudflare-pages": {{"cloudflare-pages.yaml", "deploy.yaml"}}, "docker-bake": {{"docker-bake.yaml", "build.yaml"}}, "docker-build": {{"docker-build.yaml", "build.yaml"}}, "github-pages": {{"github-pages.yaml", "deploy.yaml"}}, "go-test": {{"go-test.yaml", "go-test.yaml"}}, "goreleaser": {{"goreleaser.yaml", "release.yaml"}}, "nix": {{"nix.yaml", "deploy.yaml"}}, "node-test": {{"node-test.yaml", "node-test.yaml"}}, "osv-scanner": { {"osv-scanner-pr.yaml", "osv-scanner-pr.yaml"}, {"osv-scanner-scheduled.yaml", "osv-scanner-scheduled.yaml"}, }, "pre-commit": {{"pre-commit.yaml", "pre-commit.yaml"}}, "python-test": {{"python-test.yaml", "python-test.yaml"}}, "tangled-mirror": {{"tangled-mirror.yaml", "tangled-mirror.yaml"}}, "rust-test": {{"rust-test.yaml", "rust-test.yaml"}},}
var githubActionsCmd = &cobra.Command{ Use: "github-actions", Short: "Init Github Actions configs", ValidArgs: githubActionsOptions, Run: func(cmd *cobra.Command, args []string) { requireTemplateOption(args)
option := args[0] mappings, ok := githubActionsMapping[option] if !ok { mappings = [][2]string{{option, option}} }
template.CreateDir(filepath.Join(".github", "workflows")) for _, mapping := range mappings { template.WriteConfig("github-actions", mapping[0], filepath.Join(".github", "workflows", mapping[1])) } },}
func init() { rootCmd.AddCommand(githubActionsCmd)}