Skip to content

Commit

Permalink
scripts/detectNotUsingGitPush1by1.fsx: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tehraninasab committed Mar 23, 2023
1 parent dc1c82e commit 006fe22
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions scripts/detectNotUsingGitPush1by1.fsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
#!/usr/bin/env -S dotnet fsi

open System
open System.IO
open System.Net.Http
open System.Net.Http.Headers
open System.Text.RegularExpressions

#r "nuget: Fsdk, Version=0.6.0--date20230214-0422.git-1ea6f62"
open Fsdk

let githubEventPath = Environment.GetEnvironmentVariable "GITHUB_EVENT_PATH"

let gitRepo = Environment.GetEnvironmentVariable "GITHUB_REPOSITORY"

if String.IsNullOrEmpty gitRepo then
if String.IsNullOrEmpty githubEventPath then
Console.Error.WriteLine
"This script is meant to be used only within a GitHubCI pipeline"

Environment.Exit 2

let jsonString = File.ReadAllText(githubEventPath)

let repoRegex =
Regex("\"full_name\"\\s*:\\s*\"([^\\s]*)\"", RegexOptions.Compiled)

let gitRepo =
(repoRegex.Matches jsonString).[0].Groups.[1]
.ToString()

let currentBranch =
Process
.Execute(
Expand Down

0 comments on commit 006fe22

Please sign in to comment.