mirror of
https://github.com/go-i2p/go-gh-page.git
synced 2025-06-15 14:04:23 -04:00
Add the ability to automatically emit the CI file
This commit is contained in:
7
Makefile
7
Makefile
@ -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
|
@ -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)")
|
||||
|
@ -10,3 +10,6 @@ var DocTemplate string
|
||||
|
||||
//go:embed style.css
|
||||
var StyleTemplate string
|
||||
|
||||
//go:embed page.yml
|
||||
var CITemplate string
|
||||
|
Reference in New Issue
Block a user