- Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgit.go
More file actions
Latest commit
54 lines (36 loc) · 947 Bytes
/
Copy pathgit.go
File metadata and controls
54 lines (36 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"fmt"
"os"
"strconv"
"os/exec"
"github.com/joho/godotenv"
)
funcmain() {
godotenv.Load()
commitCount, _:=strconv.Atoi(os.Getenv("COMMIT_COUNT"))
pushThreshold, _:=strconv.Atoi(os.Getenv("PUSH_THRESHOLD"))
git:="git"
commit:="commit"
push:="push"
allow_empty:="--allow-empty"
m:="-m"
message:="'go + git + github = 💥'"
fori:=0; i<commitCount; i++ {
cmdCommit:=exec.Command(git, commit, allow_empty, m, message)
stdoutCommit, errCommit:=cmdCommit.Output()
iferrCommit!=nil {
fmt.Println("🔥 commit error: ", errCommit.Error())
return
}
fmt.Println("🚀 ",string(stdoutCommit))
if (i%pushThreshold==0) {
cmdPush:=exec.Command(git, push)
_, errPush:=cmdPush.Output()
iferrPush!=nil {
fmt.Println("🔥 push error: ", errPush.Error())
}
fmt.Println("🛬 pushed successfully")
}
}
}