mirror of
https://github.com/go-i2p/go-gh-page.git
synced 2025-06-16 22:30:53 -04:00
Add the ability to automatically emit the CI file
This commit is contained in:
5
Makefile
5
Makefile
@ -1,2 +1,5 @@
|
|||||||
fmt:
|
fmt: cp
|
||||||
find . -name '*.go' -exec gofumpt -w -s -extra {} \;
|
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"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -24,9 +25,27 @@ func main() {
|
|||||||
mainTemplateOverride := flag.String("main-template", "", "Path to custom main template")
|
mainTemplateOverride := flag.String("main-template", "", "Path to custom main template")
|
||||||
docTemplateOverride := flag.String("doc-template", "", "Path to custom documentation template")
|
docTemplateOverride := flag.String("doc-template", "", "Path to custom documentation template")
|
||||||
styleTemplateOverride := flag.String("style-template", "", "Path to custom style 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()
|
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
|
// Validate repository flag
|
||||||
if *repoFlag == "" {
|
if *repoFlag == "" {
|
||||||
fmt.Println("Error: -repo flag is required (format: owner/repo-name)")
|
fmt.Println("Error: -repo flag is required (format: owner/repo-name)")
|
||||||
|
@ -10,3 +10,6 @@ var DocTemplate string
|
|||||||
|
|
||||||
//go:embed style.css
|
//go:embed style.css
|
||||||
var StyleTemplate string
|
var StyleTemplate string
|
||||||
|
|
||||||
|
//go:embed page.yml
|
||||||
|
var CITemplate string
|
||||||
|
Reference in New Issue
Block a user