Add the ability to automatically emit the CI file

This commit is contained in:
eyedeekay
2025-05-06 17:15:49 -04:00
parent 883cc95077
commit c70745f106
3 changed files with 27 additions and 2 deletions

View File

@ -1,2 +1,5 @@
fmt:
find . -name '*.go' -exec gofumpt -w -s -extra {} \;
fmt: cp
find . -name '*.go' -exec gofumpt -w -s -extra {} \;
cp:
cp -v ./.github/workflows/page.yml pkg/templates/page.yml

View File

@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
@ -24,9 +25,27 @@ func main() {
mainTemplateOverride := flag.String("main-template", "", "Path to custom main template")
docTemplateOverride := flag.String("doc-template", "", "Path to custom documentation template")
styleTemplateOverride := flag.String("style-template", "", "Path to custom style template")
setupYaml := flag.Bool("page-yaml", false, "Generate .github/workflows/page.yaml file")
flag.Parse()
if *setupYaml {
if err := os.MkdirAll(".github/workflows", 0o755); err != nil {
log.Fatalf("Failed to create .github/workflows directory: %v", err)
}
// Generate the page.yaml file
if err := os.WriteFile(".github/workflows/page.yml", []byte(templates.CITemplate), 0o644); err != nil {
log.Fatalf("Failed to generate page.yml: %v", err)
}
fmt.Printf("Generated .github/workflows/page.yaml in %s\n", *outputFlag)
if err := exec.Command("git", "add", ".github/workflows/page.yml").Run(); err != nil {
log.Fatalf("Failed to add page.yml to git: %v", err)
}
fmt.Println("Added .github/workflows/page.yml to git staging area.")
fmt.Println("You can now commit and push this file to your repository.")
os.Exit(0)
}
// Validate repository flag
if *repoFlag == "" {
fmt.Println("Error: -repo flag is required (format: owner/repo-name)")

View File

@ -10,3 +10,6 @@ var DocTemplate string
//go:embed style.css
var StyleTemplate string
//go:embed page.yml
var CITemplate string