-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
55 lines (42 loc) · 1.16 KB
/
main.go
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
55
package main
import (
"context"
"fmt"
"os"
"os/exec"
"time"
"github.com/liamg/github-profile-terminal-action/config"
"github.com/liamg/github-profile-terminal-action/profile"
)
const outputDir = "."
func main() {
conf, err := config.Derive()
if err != nil {
fail("Configuration error: %s", err)
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
if err := profile.New(conf).Generate(ctx, outputDir); err != nil {
fail("Failed to generate profile: %s", err)
}
_ = run("ls", "-la")
if err := run("git", "add", "."); err != nil {
fail("failed to add files to git: %s", err)
}
if err := run("git", "-c", "user.name=bot", "-c", "[email protected]", "commit", "-a", "-m", "Generated by actions"); err != nil {
fail("failed to commit files to git: %s", err)
}
if err := run("git", "push"); err != nil {
fail("failed to push files to git: %s", err)
}
}
func fail(format string, args ...interface{}) {
_, _ = fmt.Fprintf(os.Stderr, format+"\n", args...)
os.Exit(1)
}
func run(cmd string, args ...string) error {
c := exec.Command(cmd, args...)
c.Stderr = os.Stderr
c.Stdout = os.Stdout
return c.Run()
}