Getting it running on Netlify

This commit is contained in:
Bjørn Erik Pedersen committed 2021-06-28 19:20:43 +02:00
1 parent fcbfdf2c92
commit 3b88aae53a
6 files changed
+29 -14

No files matched your search

+12
View File
@@ -1,2 +1,14 @@
# hugoThemeSiteBuilder
[![Netlify Status](https://api.netlify.com/api/v1/badges/faa207e4-92c4-4fd4-8f5d-b8305205fb84/deploy-status)](https://app.netlify.com/sites/inspiring-noether-f6fa3f/deploys)
Work in progress.
* Preview https://inspiring-noether-f6fa3f.netlify.app/
* Add new themes in cmd/hugothemesitebuilder/build/themes.txt
* The new script fetches star info etc. from GitHub and uses that as part of the weight (combined with date)
* The script currently does not build any demo site, but we may consider a build as part of the "theme evaluation" (as in: block themes with lots of errors, or maybe pull them down with weight).
* Similar I have added some notes about checking if `hugo_version` is set and valid.
@@ -19,14 +19,12 @@ popd() {
command popd "$@" >/dev/null
}
pushd cmd/hugothemesitebuilder
pushd "../.."
try go run main.go build
pushd build/site
popd
if [ -z "$CONTEXT" ] || [ "$CONTEXT" == "production" ]
then
try hugo --gc --minify
else
try hugo --gc --minify -b $DEPLOY_PRIME_URL
fi
popd
popd
+1 -1
View File
@@ -2,4 +2,4 @@ module github.com/gohugoio/hugoThemeSiteBuilder/cmd/hugothemesitebuilder/build/s
go 1.16
require github.com/gohugoio/hugoThemesSite v0.0.0-20210628104547-7a5b595fb9f9
require github.com/gohugoio/hugoThemesSite v0.0.0-20210628144450-4b0d4917433c
@@ -2,3 +2,5 @@ github.com/gohugoio/gohugoioTheme v0.0.0-20210301124928-2c15837dfec3/go.mod h1:k
github.com/gohugoio/hugoThemesSite v0.0.0-20210519162828-756792be83fa h1:s8I3nhH+5bXJEnTGCwYxVT2JfhgxME8SAb7iSIzlN5I=
github.com/gohugoio/hugoThemesSite v0.0.0-20210519162828-756792be83fa/go.mod h1:Gx6nWFkR+m0eRiTbtiFb1luhSp6IJ22akCXOvYdcbN4=
github.com/gohugoio/hugoThemesSite v0.0.0-20210628104547-7a5b595fb9f9/go.mod h1:Gx6nWFkR+m0eRiTbtiFb1luhSp6IJ22akCXOvYdcbN4=
github.com/gohugoio/hugoThemesSite v0.0.0-20210628144450-4b0d4917433c h1:IA0osqEnyMe7mMHmnzIuDioqXnQ+YTAVm+qf8F0ScFg=
github.com/gohugoio/hugoThemesSite v0.0.0-20210628144450-4b0d4917433c/go.mod h1:Gx6nWFkR+m0eRiTbtiFb1luhSp6IJ22akCXOvYdcbN4=
+4 -8
View File
@@ -1,19 +1,15 @@
[build]
publish = "cmd/hugothemesitebuilder/build/site/public"
command = "build.sh"
base = "cmd/hugothemesitebuilder/build/site"
publish = "public"
command = "./build.sh"
ignore = "/bin/false"
[context.production.environment]
HUGO_VERSION = "0.84.2"
[context.deploy-preview]
command = "build.sh"
[context.deploy-preview.environment]
HUGO_VERSION = "0.84.2"
[context.branch-deploy]
command = "build.sh"
[context.branch-deploy.environment]
HUGO_VERSION = "0.84.2"
+8 -1
View File
@@ -37,6 +37,8 @@ type Client struct {
}
func (c *Client) GetHugoModulesMap(config string) (ModulesMap, error) {
c.Logf("Get Hugo Modules, config %q", config)
defer c.TimeTrack(time.Now(), "Got Hugo Modules")
b := &bytes.Buffer{}
if err := c.runHugo(b, "--config", config, "config", "mounts", "-v"); err != nil {
return nil, err
@@ -48,7 +50,8 @@ func (c *Client) GetHugoModulesMap(config string) (ModulesMap, error) {
for dec.More() {
var m Module
if derr := dec.Decode(&m); derr != nil {
return nil, derr
b, _ := io.ReadAll(dec.Buffered())
return nil, fmt.Errorf("failed to decode config: %s (buf: %q)", derr, b)
}
if m.Owner == modPath {
@@ -141,6 +144,8 @@ const cacheFileSuffix = "githubrepos.json"
//
// If you start with an empty cache, you will need to set a GITHUB_TOKEN environment variable.
func (c *Client) GetGitHubRepos(mods ModulesMap) (map[string]GitHubRepo, error) {
c.Logf("Get GitHub repos")
defer c.TimeTrack(time.Now(), "Got GitHub repos")
cacheFiles := c.getGithubReposCacheFilesSorted()
m := make(map[string]GitHubRepo)
for _, cacheFile := range cacheFiles {
@@ -264,6 +269,8 @@ func (c *Client) runHugo(w io.Writer, arg ...string) error {
env := os.Environ()
setEnvVars(&env, "PWD", c.outDir) // Use the output dir as the Hugo root.
arg = append(arg, "--quiet")
cmd := exec.Command("hugo", arg...)
cmd.Env = env
cmd.Stdout = w