-
Notifications
You must be signed in to change notification settings - Fork 5
/
Utils.fs
54 lines (39 loc) · 1.08 KB
/
Utils.fs
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
module Utils
open System
open SimpleExec
let dockerCmd (subCmd: string) (args: string list) =
Command.Run("docker", subCmd :: args)
let runGitCmd (command: string) =
task {
let! out, _ = Command.ReadAsync("git", command, workingDirectory = "./")
return out
}
|> Async.AwaitTask
|> Async.RunSynchronously
let getLatestTag () =
let revListResult =
runGitCmd "rev-list --tags --max-count=1"
let tagName =
runGitCmd $"describe --tags %s{revListResult}"
tagName
let gitPush () =
let gitUsr =
Environment.GetEnvironmentVariable "GITHUB_USER"
let gitToken =
Environment.GetEnvironmentVariable "GITHUB_TOKEN"
let branch =
Environment.GetEnvironmentVariable "GITHUB_REF"
Command.Run(
"git",
[ "push"
$"https://%s{gitUsr}:%s{gitToken}@github.com/ZeekoZhu/aspnetcore-build-yarn"
$"HEAD:%s{branch}" ]
)
let checkTemplateUpdate () =
let changed = runGitCmd "ls-files -m"
printfn $"{changed}"
changed.Contains "daily-template/"
let failIfError =
function
| Result.Ok value -> value
| Result.Error err -> failwith $"%A{err}"