build: add dependencies for render targets

- add downloading the forgejo binary as a dependency to rendering the
  forgejo templates.
- add rendering the compose file as a dependency for rendering
  non-compose targets.
This commit is contained in:
Dan Anglin 2023-02-24 09:12:01 +00:00
parent 78f31ab007
commit 4e5ed6e9e5
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638

View file

@ -7,6 +7,7 @@ import (
"os"
"github.com/magefile/mage/sh"
"github.com/magefile/mage/mg"
)
const (
@ -40,13 +41,23 @@ func Clean() error {
// Render renders the template files.
func Render(name string) error {
if name == "forgejo" {
mg.Deps(DownloadForgejo)
}
cfg, err := newConfig(configFile)
if err != nil {
return fmt.Errorf("unable to load the configuration; %v", err)
}
if name != "compose" {
if err := render(cfg, "compose"); err != nil {
return fmt.Errorf("an error occurred whilst rendering the compose file; %w", err)
}
}
if err := render(cfg, name); err != nil {
return fmt.Errorf("an error occurred whilst rendering the templates; %v", err)
return fmt.Errorf("an error occurred whilst rendering the templates; %w", err)
}
return nil
@ -56,7 +67,7 @@ func Render(name string) error {
func Deploy(name string) error {
cfg, err := newConfig(configFile)
if err != nil {
return fmt.Errorf("unable to load the configuration; %v", err)
return fmt.Errorf("unable to load the configuration; %w", err)
}
os.Setenv("DOCKER_HOST", cfg.DockerHost)