Skip to content

🩹 [Patch]: Standardize project structure and rename release workflow - #81

Merged
Marius Storhaug (MariusStorhaug) merged 4 commits into
mainfrom
rename-auto-release
Jan 25, 2026
Merged

Marius Storhaug (MariusStorhaug) merged 4 commits into
mainfrom
rename-auto-release

Conversation

@MariusStorhaug

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Jan 25, 2026 •

Copy link
Copy Markdown
Member

This PR standardizes the project structure and updates workflows to align with PSModule conventions.

Changed

  • Rename Auto-Release.yml workflow to Release.yml for consistency
  • Update release action from PSModule/Auto-Release@v1.9.5 to PSModule/Release-GHRepository@v2
  • Rename scripts/ folder to src/ to follow standard project layout
  • Update action.yml to reference scripts from new src/ location
  • Add linter workflow configuration

Removed

  • Remove unused .jscpd.json linter configuration file

Summary

This PR brings the GitHub-Script action in line with PSModule's standardized project structure. The scripts/ folder is renamed to src/ for consistency across all actions, and the release workflow is updated to use the renamed Release-GHRepository action.

Comment thread action.yml
try {
${{ github.action_path }}/scripts/init.ps1
${{ github.action_path }}/scripts/info.ps1
${{ github.action_path }}/src/init.ps1

Check warning

Code scanning / CodeQL

Code injection

Potential code injection in [${{ github.action_path }}](1), which may be controlled by an external user.

Copilot Autofix

AI 10 months ago

In general, to address code injection warnings in GitHub Actions, move expression values (${{ ... }}) into environment variables and then reference them using the shell’s native syntax instead of embedding expressions directly inside the run: script. This eliminates the opportunity for shell parsing of templated strings and aligns with GitHub’s recommended pattern.

For this specific file, we should:

  1. Define an environment variable (for example PSMODULE_GITHUB_ACTION_PATH) set to ${{ github.action_path }} under env: for the step.
  2. Replace all occurrences of ${{ github.action_path }} in the PowerShell script with the PowerShell environment variable reference $env:PSMODULE_GITHUB_ACTION_PATH.
  3. While doing so, preserve the rest of the logic and keep ${{ inputs.Script }} untouched, since changing that behavior would alter functionality and go beyond the requested change.

Concretely, in action.yml within the composite runs.steps block for RunGitHubScript, we add a new env: entry (e.g., on a new line after line 95) and then adjust lines 102–105 and 108 so that they call the PowerShell scripts using $env:PSMODULE_GITHUB_ACTION_PATH instead of ${{ github.action_path }}. No additional external dependencies or imports are required.

Suggested changeset 1
action.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/action.yml b/action.yml
--- a/action.yml
+++ b/action.yml
@@ -93,17 +93,18 @@
         PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
         PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
         PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
+        PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
       run: |
         # ${{ inputs.Name }}
         $ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
         $DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
         $VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
         try {
-          ${{ github.action_path }}/src/init.ps1
-          ${{ github.action_path }}/src/info.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/init.ps1"
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/info.ps1"
           ${{ inputs.Script }}
-          ${{ github.action_path }}/src/outputs.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/outputs.ps1"
         }
         finally {
-          ${{ github.action_path }}/src/clean.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/clean.ps1"
         }
EOF
@@ -93,17 +93,18 @@
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
run: |
# ${{ inputs.Name }}
$ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
$DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
$VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
try {
${{ github.action_path }}/src/init.ps1
${{ github.action_path }}/src/info.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/init.ps1"
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/info.ps1"
${{ inputs.Script }}
${{ github.action_path }}/src/outputs.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/outputs.ps1"
}
finally {
${{ github.action_path }}/src/clean.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/clean.ps1"
}
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread action.yml
${{ github.action_path }}/scripts/init.ps1
${{ github.action_path }}/scripts/info.ps1
${{ github.action_path }}/src/init.ps1
${{ github.action_path }}/src/info.ps1

Check warning

Code scanning / CodeQL

Code injection

Potential code injection in [${{ github.action_path }}](1), which may be controlled by an external user.

Copilot Autofix

AI 10 months ago

General fix: avoid using ${{ ... }} expressions directly inside the run: script. Instead, assign those values to environment variables (or to action inputs that are already mapped to env vars), and inside the PowerShell script refer to them via $env:VAR or normal PowerShell variables. This follows GitHub’s recommended pattern and prevents the expression language from being mixed with shell syntax.

Concrete change here: we will add an environment variable (e.g. PSMODULE_GITHUB_ACTION_PATH) set to ${{ github.action_path }}, and then update the PowerShell script so it invokes the scripts via $env:PSMODULE_GITHUB_ACTION_PATH\src\*.ps1. That way, no ${{ ... }} appears inside the run: block for these paths, and CodeQL’s injection concern is removed, while functionality remains the same. We will not alter ${{ inputs.Script }} because the entire action is built around intentionally executing that content as PowerShell.

Changes to make in action.yml:

  • In the env: section of the RunGitHubScript step, add:
    • PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
  • In the run: script:
    • Replace:
      • ${{ github.action_path }}/src/init.ps1
      • ${{ github.action_path }}/src/info.ps1
      • ${{ github.action_path }}/src/outputs.ps1
      • ${{ github.action_path }}/src/clean.ps1
    • With proper PowerShell invocations that reference the environment variable, e.g.:
      • & "$env:PSMODULE_GITHUB_ACTION_PATH/src/init.ps1"
      • etc.

Using & ensures the script is actually executed as a PowerShell script even if the path contains spaces. All other behavior (inputs, outputs) remains unchanged.

No extra imports or external libraries are necessary; all changes are within action.yml.


Suggested changeset 1
action.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/action.yml b/action.yml
--- a/action.yml
+++ b/action.yml
@@ -93,17 +93,18 @@
         PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
         PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
         PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
+        PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
       run: |
         # ${{ inputs.Name }}
         $ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
         $DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
         $VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
         try {
-          ${{ github.action_path }}/src/init.ps1
-          ${{ github.action_path }}/src/info.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/init.ps1"
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/info.ps1"
           ${{ inputs.Script }}
-          ${{ github.action_path }}/src/outputs.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/outputs.ps1"
         }
         finally {
-          ${{ github.action_path }}/src/clean.ps1
+          & "$env:PSMODULE_GITHUB_ACTION_PATH/src/clean.ps1"
         }
EOF
@@ -93,17 +93,18 @@
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
run: |
# ${{ inputs.Name }}
$ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
$DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
$VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
try {
${{ github.action_path }}/src/init.ps1
${{ github.action_path }}/src/info.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/init.ps1"
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/info.ps1"
${{ inputs.Script }}
${{ github.action_path }}/src/outputs.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/outputs.ps1"
}
finally {
${{ github.action_path }}/src/clean.ps1
& "$env:PSMODULE_GITHUB_ACTION_PATH/src/clean.ps1"
}
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread action.yml
${{ github.action_path }}/src/info.ps1
${{ inputs.Script }}
${{ github.action_path }}/scripts/outputs.ps1
${{ github.action_path }}/src/outputs.ps1

Check warning

Code scanning / CodeQL

Code injection

Potential code injection in [${{ github.action_path }}](1), which may be controlled by an external user.

Copilot Autofix

AI 10 months ago

General approach: Avoid embedding GitHub expression syntax (${{ ... }}) directly in the run: script where it becomes part of the PowerShell code. Instead, assign those values to environment variables (already done for inputs) or to step outputs, and then read and use them via native PowerShell syntax ($env:VAR, variables, & to invoke scripts). For script paths, construct them from a safe base directory in PowerShell rather than concatenating expression results into the script body.

Best concrete fix here:

  1. Add an environment variable (or variables) in the step’s env: section that captures github.action_path as a value, e.g. PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}.
  2. Update the PowerShell run: block so it does not contain ${{ github.action_path }} or ${{ inputs.Script }} directly. Instead:
    • Define a PowerShell variable $actionPath = $env:PSMODULE_GITHUB_ACTION_PATH.
    • Safely build the script paths using Join-Path $actionPath 'src/init.ps1', etc., and execute them via & (the call operator).
    • Move the user-supplied script out of the expression context: pass inputs.Script via an env var (e.g. PSMODULE_GITHUB_SCRIPT_INPUT_Script) and invoke it using PowerShell’s Invoke-Expression on that env var. This avoids GitHub expression injection; note that if inputs.Script itself is attacker-controlled PowerShell code, that is by design for this action (it runs arbitrary user PowerShell), so we only need to prevent extra commands being smuggled through the GitHub expression layer.
  3. Keep existing behavior: the same init, info, user script, outputs, and clean scripts still run in the same order; inputs already exposed via env remain unchanged.

Concretely, within action.yml we will:

  • Add a new env entry: PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}.
  • Add a new env entry for the script text: PSMODULE_GITHUB_SCRIPT_INPUT_Script: ${{ inputs.Script }}.
  • Replace the body of the run: block to:
    • Set $actionPath and $scriptToRun from the environment.
    • Use Join-Path and & to run init.ps1, info.ps1, the user script, outputs.ps1, and clean.ps1.

Suggested changeset 1
action.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/action.yml b/action.yml
--- a/action.yml
+++ b/action.yml
@@ -93,17 +93,23 @@
         PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
         PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
         PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
+        PSMODULE_GITHUB_SCRIPT_INPUT_Script: ${{ inputs.Script }}
+        PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
       run: |
         # ${{ inputs.Name }}
         $ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
         $DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
         $VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
+        $actionPath = $env:PSMODULE_GITHUB_ACTION_PATH
+        $scriptToRun = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Script
         try {
-          ${{ github.action_path }}/src/init.ps1
-          ${{ github.action_path }}/src/info.ps1
-          ${{ inputs.Script }}
-          ${{ github.action_path }}/src/outputs.ps1
+          & (Join-Path $actionPath 'src/init.ps1')
+          & (Join-Path $actionPath 'src/info.ps1')
+          if ($scriptToRun) {
+            Invoke-Expression $scriptToRun
+          }
+          & (Join-Path $actionPath 'src/outputs.ps1')
         }
         finally {
-          ${{ github.action_path }}/src/clean.ps1
+          & (Join-Path $actionPath 'src/clean.ps1')
         }
EOF
@@ -93,17 +93,23 @@
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
PSMODULE_GITHUB_SCRIPT_INPUT_Script: ${{ inputs.Script }}
PSMODULE_GITHUB_ACTION_PATH: ${{ github.action_path }}
run: |
# ${{ inputs.Name }}
$ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
$DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
$VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
$actionPath = $env:PSMODULE_GITHUB_ACTION_PATH
$scriptToRun = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Script
try {
${{ github.action_path }}/src/init.ps1
${{ github.action_path }}/src/info.ps1
${{ inputs.Script }}
${{ github.action_path }}/src/outputs.ps1
& (Join-Path $actionPath 'src/init.ps1')
& (Join-Path $actionPath 'src/info.ps1')
if ($scriptToRun) {
Invoke-Expression $scriptToRun
}
& (Join-Path $actionPath 'src/outputs.ps1')
}
finally {
${{ github.action_path }}/src/clean.ps1
& (Join-Path $actionPath 'src/clean.ps1')
}
Copilot is powered by AI and may make mistakes. Always verify output.
Comment thread action.yml
}
finally {
${{ github.action_path }}/scripts/clean.ps1
${{ github.action_path }}/src/clean.ps1

Check warning

Code scanning / CodeQL

Code injection

Potential code injection in [${{ github.action_path }}](1), which may be controlled by an external user.

Copilot Autofix

AI 10 months ago

In general, to fix this type of issue in GitHub Actions, any value coming from a GitHub expression (${{ ... }}), whether or not it is attacker-controlled, should be assigned to an environment variable and then referenced using the shell’s native syntax ($VAR in PowerShell) inside the run: block. This avoids the risk of expression-based code injection inside scripts.

For this file, the safest, minimal-change fix is:

  1. Define an environment variable (for example, ACTION_PATH) in the env: section with the value ${{ github.action_path }}.
  2. Replace all usages of ${{ github.action_path }} in the run: script with $env:ACTION_PATH, which is standard PowerShell syntax for environment variables.
  3. Leave ${{ inputs.Script }} as-is, because that is the intended script content input to the action; the CodeQL report specifically targets the github.action_path expression.

Concretely, within action.yml:

  • Under env: for the RunGitHubScript step, add a line ACTION_PATH: ${{ github.action_path }} (or similarly named variable).
  • In the run: block, change:
    • ${{ github.action_path }}/src/init.ps1 → $env:ACTION_PATH/src/init.ps1
    • ${{ github.action_path }}/src/info.ps1 → $env:ACTION_PATH/src/info.ps1
    • ${{ github.action_path }}/src/outputs.ps1 → $env:ACTION_PATH/src/outputs.ps1
    • ${{ github.action_path }}/src/clean.ps1 → $env:ACTION_PATH/src/clean.ps1

No additional imports or external libraries are needed; this is purely a YAML and PowerShell syntax adjustment.

Suggested changeset 1
action.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/action.yml b/action.yml
--- a/action.yml
+++ b/action.yml
@@ -93,17 +93,18 @@
         PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
         PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
         PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
+        ACTION_PATH: ${{ github.action_path }}
       run: |
         # ${{ inputs.Name }}
         $ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
         $DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
         $VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
         try {
-          ${{ github.action_path }}/src/init.ps1
-          ${{ github.action_path }}/src/info.ps1
+          $env:ACTION_PATH/src/init.ps1
+          $env:ACTION_PATH/src/info.ps1
           ${{ inputs.Script }}
-          ${{ github.action_path }}/src/outputs.ps1
+          $env:ACTION_PATH/src/outputs.ps1
         }
         finally {
-          ${{ github.action_path }}/src/clean.ps1
+          $env:ACTION_PATH/src/clean.ps1
         }
EOF
@@ -93,17 +93,18 @@
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
ACTION_PATH: ${{ github.action_path }}
run: |
# ${{ inputs.Name }}
$ErrorView = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
$DebugPreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue'
$VerbosePreference = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue'
try {
${{ github.action_path }}/src/init.ps1
${{ github.action_path }}/src/info.ps1
$env:ACTION_PATH/src/init.ps1
$env:ACTION_PATH/src/info.ps1
${{ inputs.Script }}
${{ github.action_path }}/src/outputs.ps1
$env:ACTION_PATH/src/outputs.ps1
}
finally {
${{ github.action_path }}/src/clean.ps1
$env:ACTION_PATH/src/clean.ps1
}
Copilot is powered by AI and may make mistakes. Always verify output.
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title 🩹[Patch]: Rename Auto-Release to Release-GHRepository 🩹 [Patch]: Standardize project structure and rename release workflow Jan 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes the GitHub-Script action's project structure by renaming the scripts/ folder to src/ to align with PSModule conventions, and updates the release workflow to use the renamed action and improved naming.

Changes:

  • Renamed scripts/ folder to src/ for consistency with PSModule project structure
  • Updated workflow from Auto-Release to Release and migrated from PSModule/Auto-Release@v1.9.5 to PSModule/Release-GHRepository@v2.0.1
  • Disabled JSCPD validation in linter and removed its configuration file

Reviewed changes

Copilot reviewed 4 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/outputs.ps1 Moved from scripts/ with logic for displaying script outputs
src/init.ps1 Moved from scripts/ with initialization and module setup logic
src/info.ps1 Moved from scripts/ with environment information display logic
src/clean.ps1 Moved from scripts/ with cleanup logic for credentials
action.yml Updated all script path references from scripts/ to src/
.github/workflows/Release.yml Renamed workflow, updated action reference, and added paths filter
.github/workflows/Linter.yml Disabled JSCPD validation
.github/linters/.jscpd.json Removed unused linter configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

This branch was previously deployed

1 inactive deployment
azure — 1f1fcc35 Deployed Jan 25, 2026 by MariusStorhaug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants