Skip to content

Commit bf06e98

Browse files
committed
Added commands to build book
1 parent f71af9e commit bf06e98

File tree

3 files changed

+59
-4
lines changed

3 files changed

+59
-4
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pubbook
2+
pubbook.exe
3+

docker/gopath/src/xogeny/pubbook/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,14 @@ docker server where it can be extracted for the build process. This
1111
is necessary because this build requires additional files beyond just
1212
the instructions contained in the `Dockerfile`. Those additional
1313
files need to be available for the build (which is not done locally).
14+
15+
# Running
16+
17+
When running this container, it is important to provide some
18+
information on `docker` command line. Specifically, the following
19+
environment variables should be provided to the container:
20+
21+
* AWS_ACCESS_KEY_ID
22+
* AWS_SECRET_ACCESS_KEY
23+
* MBE_WEBHOOK_SECRET
24+
Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,61 @@
11
package main
22

3+
import "os"
4+
import "fmt"
35
import "log"
6+
import "os/exec"
47

58
import hs "github.com/xogeny/go-hooksink"
69

710
type Builder struct {}
811

912
func (b Builder) Push(msg hs.HubMessage) {
10-
/* Checkout repo locally */
13+
url := "git@github.com:xogeny/ModelicaBook.git"
14+
ref := "master"
15+
target := "web_cn"
16+
user := "xogeny"
17+
repo := "ModelicaBook"
18+
dir := "temp"
19+
20+
defer func() {
21+
os.RemoveAll(dir);
22+
if err != nil {
23+
log.Printf("Error cleaning up directory '%v': %s", cmd, err.Error());
24+
}
25+
}();
26+
27+
/* Clone repo locally */
28+
cmd := exec.Command("git", "clone", url, dir)
29+
err := cmd.Run()
30+
if err != nil {
31+
log.Printf("Error cloning repository at '%s' to directory %s: %s",
32+
url, dir, err.Error());
33+
return;
34+
}
35+
36+
/* Repo checkout correct ref */
37+
cmd = exec.Command("git", "checkout", ref)
38+
err = cmd.Run()
39+
if err != nil {
40+
log.Printf("Error checking out '%s': %s", ref, err.Error());
41+
return;
42+
}
43+
1144
/* Run make */
12-
/* Clean up */
13-
log.Printf("PUSH: %v", msg);
45+
bucket := fmt.Sprintf("S3BUCKET=dev.book.xogeny.com/%s/%s", user, repo);
46+
cmd = exec.Command("make", target, bucket);
47+
cmd.Dir = dir;
48+
err = cmd.Run()
49+
if err != nil {
50+
log.Printf("Error running make '%v': %s", cmd, err.Error());
51+
return;
52+
}
53+
54+
log.Printf("Make ran!");
1455
}
1556

1657
func main() {
17-
h := hs.NewHookSink("ssshhhh!");
58+
h := hs.NewHookSink("");
1859
h.Add("/build", Builder{});
1960
h.Start();
2061
}

0 commit comments

Comments
 (0)