Actions fail when writing to GITHUB_ENV in separate repository #13924

Open
opened 2025-11-02 10:57:24 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @noetzold on GitHub (Jan 7, 2025).

Description

Im using powershell on windows system and my action fails when write to GITHUB_ENV is performent in seperate repository.

Here is a test yml file to reproduce the issue:

name: build
on:
  push:
    branches:
      - '**'

defaults:
  run:
    shell: powershell

env:
  ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}}

jobs:
  Build:
    runs-on: windows
    steps:
      - name: Test1
        run: echo "TEST_VAR1=Hello" >> $env:GITHUB_ENV

      - name: Test2
        uses: https://${{ secrets.ACCESS_TOKEN }}@xyz/actions/gitea-issue@master

      - name: Print test 2
        if: ${{ always() }}
        run: echo "TestVar2 $env:TEST_VAR2"

gitea-issue repository action.yml:

name: 'Set up gitea issue'

defaults:
  run:
    shell: powershell

runs:
  using: "composite"
  steps:
    - name: Test1
      run: echo "TEST_VAR2=Hello2" >> $env:GITHUB_ENV

Step Test1 runs fine while Test2 fails.
There is no error message.
image

If I start the runner on a different PC with the same workflow, it works:
image
I do not know if it is the reason but the failing runner is on Windows 11 while the working one is on Windows 10.

Gitea Version

1.22.6

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Gitea runs from docker

Database

MySQL/MariaDB

Originally created by @noetzold on GitHub (Jan 7, 2025). ### Description Im using powershell on windows system and my action fails when write to GITHUB_ENV is performent in seperate repository. Here is a test yml file to reproduce the issue: ``` name: build on: push: branches: - '**' defaults: run: shell: powershell env: ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}} jobs: Build: runs-on: windows steps: - name: Test1 run: echo "TEST_VAR1=Hello" >> $env:GITHUB_ENV - name: Test2 uses: https://${{ secrets.ACCESS_TOKEN }}@xyz/actions/gitea-issue@master - name: Print test 2 if: ${{ always() }} run: echo "TestVar2 $env:TEST_VAR2" ``` gitea-issue repository action.yml: ``` name: 'Set up gitea issue' defaults: run: shell: powershell runs: using: "composite" steps: - name: Test1 run: echo "TEST_VAR2=Hello2" >> $env:GITHUB_ENV ``` Step Test1 runs fine while Test2 fails. There is no error message. ![image](https://github.com/user-attachments/assets/3ca84d17-68da-493a-9b92-ecb7231d4d53) If I start the runner on a different PC with the same workflow, it works: ![image](https://github.com/user-attachments/assets/5bc91221-782d-45d1-91f1-a501f37dc932) I do not know if it is the reason but the failing runner is on Windows 11 while the working one is on Windows 10. ### Gitea Version 1.22.6 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Gitea runs from docker ### Database MySQL/MariaDB
GiteaMirror added the topic/gitea-actionstype/bug labels 2025-11-02 10:57:24 -06:00
Author
Owner

@lunny commented on GitHub (Jan 7, 2025):

Are there any logs from the failed step?

@lunny commented on GitHub (Jan 7, 2025): Are there any logs from the failed step?
Author
Owner

@noetzold commented on GitHub (Jan 7, 2025):

Not in the action view or in the runner output. Is there another place?

@noetzold commented on GitHub (Jan 7, 2025): Not in the action view or in the runner output. Is there another place?
Author
Owner

@ChristopherHX commented on GitHub (Jan 7, 2025):

Might be unrelated to your failure: The following syntax is not valid in action.yml and is discarded by the original nektos/act implementation and currently only allowed in act_runner while nektos/act switched to show errors if run steps have no shell in composite actions

defaults:
  run:
    shell: powershell

It is possible that your shell becomes pwsh (or even bash, sh in docker/linux/macos/freebsd) if installed in action.yml as result. Might be unrelated

@ChristopherHX commented on GitHub (Jan 7, 2025): _Might be unrelated to your failure_: The following syntax is not valid in action.yml and is **discarded by the original nektos/act implementation and currently only allowed in act_runner _while nektos/act switched to show errors if run steps have no shell in composite actions_** ```yaml defaults: run: shell: powershell ``` _It is possible that your shell becomes `pwsh` (or even `bash`, `sh` in docker/linux/macos/freebsd) if installed in action.yml as result. Might be unrelated_
Author
Owner

@noetzold commented on GitHub (Jan 8, 2025):

Thank you @ChristopherHX for pointing me in the right direction.

The working system has "PowerShell Core" installed, the other one does not. If "PowerShell Core" is missing, the default is "PowerShell Desktop". https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
This explains the difference.

But why writing to Write-Output "TEST_VAR=Hello" >> $env:GITHUB_ENV fails in PowerShell Desktop I do not know. I am fine with the workaround of using PowerShell Core instead.

Here is a slightly more sophisticated action to reproduce this:

name: build
on:
  push:
    branches:
      - '**'

env:
  ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}}

jobs:
  Build:
    runs-on: windows
    steps:
      - name: Test
        uses: https://${{ secrets.ACCESS_TOKEN }}@git.xyz.de/actions/gitea-issue@master

      - name: Print test
        if: ${{ always() }}
        run: echo "TestVar= $env:TEST_VAR"
name: 'Set up gitea issue'

runs:
  using: "composite"
  steps:
    - name: Test
      shell: powershell
      run: |
        $host.Version
        Write-Output "TEST_VAR=Hello" >> $env:GITHUB_ENV
        get-content $env:GITHUB_ENV

Here is the log of this run action-Build-533.log

image

@noetzold commented on GitHub (Jan 8, 2025): Thank you @ChristopherHX for pointing me in the right direction. The working system has "PowerShell Core" installed, the other one does not. If "PowerShell Core" is missing, the default is "PowerShell Desktop". https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell This explains the difference. But why writing to `Write-Output "TEST_VAR=Hello" >> $env:GITHUB_ENV` fails in PowerShell Desktop I do not know. I am fine with the workaround of using PowerShell Core instead. Here is a slightly more sophisticated action to reproduce this: ``` name: build on: push: branches: - '**' env: ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}} jobs: Build: runs-on: windows steps: - name: Test uses: https://${{ secrets.ACCESS_TOKEN }}@git.xyz.de/actions/gitea-issue@master - name: Print test if: ${{ always() }} run: echo "TestVar= $env:TEST_VAR" ``` ``` name: 'Set up gitea issue' runs: using: "composite" steps: - name: Test shell: powershell run: | $host.Version Write-Output "TEST_VAR=Hello" >> $env:GITHUB_ENV get-content $env:GITHUB_ENV ``` Here is the log of this run [action-Build-533.log](https://github.com/user-attachments/files/18346066/action-Build-533.log) ![image](https://github.com/user-attachments/assets/a62ce505-c894-4b60-918b-606d043e4b94)
Author
Owner

@ChristopherHX commented on GitHub (Jan 8, 2025):

But why writing to Write-Output "TEST_VAR=Hello" >> $env:GITHUB_ENV fails in PowerShell Desktop I do not know. I am fine with the workaround of using PowerShell Core instead.

I think that I remember... this is an default encoding problem that has been fixed in pwsh core

PowerShell versions 5.1 and below (shell: powershell) do not use UTF-8 by default, so you must specify the UTF-8 encoding. For example:

See https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions?tool=powershell#environment-files

Selecting powershell in docs is needed to see this

Beyond the logging issue of act_runner not showing the error everything works like expected in my point of view

@ChristopherHX commented on GitHub (Jan 8, 2025): > But why writing to `Write-Output "TEST_VAR=Hello" >> $env:GITHUB_ENV` fails in PowerShell Desktop I do not know. I am fine with the workaround of using PowerShell Core instead. I think that I remember... this is an default encoding problem that has been fixed in pwsh core > PowerShell versions 5.1 and below (shell: powershell) do not use UTF-8 by default, so you must specify the UTF-8 encoding. For example: See https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions?tool=powershell#environment-files _Selecting powershell in docs is needed to see this_ _Beyond the logging issue of act_runner not showing the error everything works like expected in my point of view_
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13924