From bff0b670018757fd47a2b8d2a65dc84534db2918 Mon Sep 17 00:00:00 2001 From: kRYstall9 Date: Sat, 14 Mar 2026 03:29:48 +0100 Subject: [PATCH 1/4] fix: improve .env var handling and update build exclusions --- EnvAutoUpdater.csproj | 9 +++++++++ src/Services/EnvUpdaterService.cs | 12 +++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/EnvAutoUpdater.csproj b/EnvAutoUpdater.csproj index 0029708..5e8fe4c 100644 --- a/EnvAutoUpdater.csproj +++ b/EnvAutoUpdater.csproj @@ -11,6 +11,15 @@ + + + + + + + + + diff --git a/src/Services/EnvUpdaterService.cs b/src/Services/EnvUpdaterService.cs index de06cf7..b4a8895 100644 --- a/src/Services/EnvUpdaterService.cs +++ b/src/Services/EnvUpdaterService.cs @@ -204,8 +204,15 @@ public Task> UpdateEnvFile(List localEnvVars, List { try { + var regex = new Regex($@"^#+\s*{Regex.Escape(repoVar)}\s*=", RegexOptions.Singleline); string repoLine = repoEnvContent.FirstOrDefault(line => line.StartsWith(repoVar)) ?? string.Empty; + if (string.IsNullOrEmpty(repoLine)) + { + _logger.LogDebug($"The variable {repoVar} might be commented out. Retrying"); + repoLine = repoEnvContent.FirstOrDefault(line => regex.IsMatch(line)) ?? string.Empty; + } + if (string.IsNullOrEmpty(repoLine)) { _logger.LogWarning($"The variable '{repoVar}' was expected to be found in the repository .env content but was not located. Skipping this variable."); @@ -214,7 +221,7 @@ public Task> UpdateEnvFile(List localEnvVars, List int repoLineIndex = Array.IndexOf(repoEnvContent, repoLine); - repoLine = "# " + repoLine; // Comment out the variable line from the repo to avoid issues + repoLine = repoLine.TrimStart().StartsWith('#') ? repoLine : "# " + repoLine; // Comment out the variable line from the repo to avoid issues //Expect to find multi line variable values, like a json string, so we need to check for the end of the variable value by looking for the next line that starts with a new variable or is empty or a comment if (repoLineIndex < repoEnvContent.Length - 1) @@ -225,7 +232,7 @@ public Task> UpdateEnvFile(List localEnvVars, List { break; } - repoLine += "\n# " + repoEnvContent[i]; + repoLine += repoEnvContent[i].TrimStart().StartsWith('#') ? repoEnvContent[i] : "\n# " + repoEnvContent[i]; } } @@ -250,7 +257,6 @@ public Task> UpdateEnvFile(List localEnvVars, List { _logger.LogDebug($"The environment variable '{repoVar}' is already present in the local .env file. Proceeding to update the comments"); - var regex = new Regex($@"^#+\s*{Regex.Escape(repoVar)}\s*=", RegexOptions.Singleline); int localLineIndex = result.FindIndex(line => line.StartsWith(repoVar)); if (localLineIndex == -1) From a99cea6c11b4c6afff508f834d7f86ba1ad93e86 Mon Sep 17 00:00:00 2001 From: kRYstall9 Date: Sat, 14 Mar 2026 03:46:44 +0100 Subject: [PATCH 2/4] chore: add codeql-analysis as dependency for release job --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b1c1737..af305b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,7 +64,7 @@ jobs: release: name: Semantic Release & Docker Push runs-on: ubuntu-latest - needs: test + needs: [test, codeql-analysis] steps: - name: Checkout From 5ba8a1a8dba46c4e337d9ecc8ab93170157b41e6 Mon Sep 17 00:00:00 2001 From: kRYstall9 Date: Sat, 14 Mar 2026 03:52:00 +0100 Subject: [PATCH 3/4] merge from main --- .github/workflows/pr-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml index d4ea15b..c6fe559 100644 --- a/.github/workflows/pr-tests.yml +++ b/.github/workflows/pr-tests.yml @@ -1,4 +1,6 @@ name: PR Tests +permissions: + contents: read on: pull_request: From d79fbfce6e9758a45e281dbeb6a5302ed13b1f5d Mon Sep 17 00:00:00 2001 From: kRYstall9 Date: Sat, 14 Mar 2026 04:07:25 +0100 Subject: [PATCH 4/4] chore: removed codeql-analysis from needs --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af305b6..a5dad2f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,7 +64,7 @@ jobs: release: name: Semantic Release & Docker Push runs-on: ubuntu-latest - needs: [test, codeql-analysis] + needs: [test] steps: - name: Checkout