nektos / act

Run your GitHub Actions locally 🚀
https://nektosact.com
MIT License
55.84k stars 1.4k forks source link

PowerShell steps load profile during execution #2545

Open HeyItsGilbert opened 5 days ago

HeyItsGilbert commented 5 days ago

Expected Behavior

Running a PowerShell script or command should run in it's own process without a profile being loaded.

Current Behavior

Currently the invocation runs powershell.exe -command . {0} where the commands are replaced in.

Possible Solution

Append -NoProfile to the powershell/pwsh calls.`

Steps to Reproduce

  1. On the instance running the command create a profile.
  2. Create a github workflow that runs powershell.
on:
  push:
jobs:
  test:
    runs-on: windows-latest
  steps:
    - run: |
      Write-Host "Hello world"
  1. Run act on the workflow while using -self-hosted
    • act --platform windows-latest=-self-hosted --workflows "./.github/workflows/helloworld.yaml"
  2. See error

Context

We are currently attach with -P windows=self-host on a windows machine.

HeyItsGilbert commented 5 days ago

Probably should be associated with #1608

ChristopherHX commented 4 days ago

My expected behavior is to keep this in sync with the actions/runner program

shell: powershell.exe -NoProfile -command . '{0}' is well supported by both

HeyItsGilbert commented 4 days ago

I can totally understand why you would want to do that. I don't think they worry about that since they would never have profiles (that I know of). Nor would this ever be an issue on containers. The problem is when you run this on a local machine.

It feels like a bad trade off for users to have to edit all their workflows vs adding an additional flag. If you're keeping this in sync programmatically then I can try to submit the PR to the actions/runner repository.

HeyItsGilbert commented 4 days ago

I think I may have found a compromise. Since the env contains ACT, users can use that to skip loading potentially conflicting profiles.