From 006fe222f6911bb3a522325388f6ee339e986120 Mon Sep 17 00:00:00 2001 From: realmarv Date: Thu, 23 Mar 2023 13:02:36 +0330 Subject: [PATCH] scripts/detectNotUsingGitPush1by1.fsx: fix --- scripts/detectNotUsingGitPush1by1.fsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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(