diff --git a/scripts/detectNotUsingGitPush1by1.fsx b/scripts/detectNotUsingGitPush1by1.fsx index 02196d9fd..fd4a139d8 100644 --- a/scripts/detectNotUsingGitPush1by1.fsx +++ b/scripts/detectNotUsingGitPush1by1.fsx @@ -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(