-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
67 lines (57 loc) · 1.72 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
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"context"
"fmt"
"os"
"strings"
"github.com/speakeasy-api/sdk-generation-action/internal/telemetry"
"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
"github.com/speakeasy-api/sdk-generation-action/internal/actions"
"github.com/speakeasy-api/sdk-generation-action/internal/environment"
"golang.org/x/exp/slices"
)
func main() {
if environment.IsDebugMode() {
envs := os.Environ()
slices.SortFunc(envs, func(i, j string) int {
iKey, iValue, _ := strings.Cut(i, "=")
jKey, jValue, _ := strings.Cut(j, "=")
comp := strings.Compare(iKey, jKey)
if comp != 0 {
return comp
}
return strings.Compare(iValue, jValue)
})
for _, env := range envs {
fmt.Println(env)
}
}
var err error
// Don't fire CI_Exec telemetry on actions where we are only sending specific telemetry back.
if environment.GetAction() == environment.ActionLog {
err = actions.LogActionResult()
} else if environment.GetAction() == environment.ActionPublishEvent {
err = actions.PublishEventAction()
} else {
err = telemetry.Track(context.Background(), shared.InteractionTypeCiExec, func(ctx context.Context, event *shared.CliEvent) error {
switch environment.GetAction() {
case environment.ActionSuggest:
return actions.Suggest()
case environment.ActionRunWorkflow:
return actions.RunWorkflow()
case environment.ActionFinalizeSuggestion:
return actions.FinalizeSuggestion()
case environment.ActionRelease:
return actions.Release()
case environment.ActionTag:
return actions.Tag()
default:
return fmt.Errorf("unknown action: %s", environment.GetAction())
}
})
}
if err != nil {
fmt.Printf("::error title=failed::%v\n", err)
os.Exit(1)
}
}