I have a self-hosted GitHub Action Runner that builds a Visual Studio solution and then launches a powershell script that lives inside the repo. This script modifies some files in the repo. I would like these modified files to also be copied to a folder outside the GitHub Action Runner directory as the last step of my action within my PC (Windows 10). This is what the launched script looks like:
$scriptFile = Get-Item ".\SFDScripts\Internal\Hardcore\Hardcore.cs"
$maps = Get-ChildItem ".\SFDScripts\Internal\Hardcore\Maps\"
foreach ($map in $maps) {
if ($map.PSIsContainer) { continue }
# This modifies the file at {$map.FullName}
SFDScriptInjector $scriptFile.FullName $map.FullName
# Then I want to copy that file to a specific directory on the device where the GitHub Action Runner runs
Copy-Item $map.FullName "C:\Users\juans\OneDrive\Documents\Superfighters Deluxe\Maps\Custom"
}
I am currently getting an error at the Copy-Item $map.FullName "C:\Users\juans\OneDrive\Documents\Superfighters Deluxe\Maps\Custom"
line. The error is the following
Copy-Item : Access is denied
At E:\actions-runner\_work\SFDScripts\SFDScripts\injectScriptToAllMaps.ps1:7 char:5
+ Copy-Item $map.FullName "C:\Users\juans\OneDrive\Documents\Superf ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.CopyItemCommand
Error: Process completed with exit code 1.
I also tried running the script using this run_as.ps1
script. This allows the Action to finish without errors, but the files are still not copied (I'm guessing it fails silently inside the new instance of powershell.
Here is the .yml action file at its current state.
I can't find out how to give access to the github runner to modify external directories. So, how can I make it to copy the file to an external directory?