如何在Windows最新版的GitHub操作中显示github步骤摘要

rjee0c15  于 2023-02-09  发布在  Windows
关注(0)|答案(1)|浏览(129)

我无法在windows上为github操作生成summary。下面的脚本封装了这个脚本。
使用以下脚本:

name: Testing windows summaries

on:
  pull_request:
    branches: [master]
    types: [synchronize, opened, reopened, ready_for_review]

jobs:
  build-and-test:
    name: Test
    runs-on: "windows-latest"
    steps:
    - name: Adding markdown
      run: |
       echo '### Hello world! ' >> $GITHUB_STEP_SUMMARY
       cat $GITHUB_STEP_SUMMARY

产生以下错误:

Get-Content: D:\a\_temp\e90ee597-2b32-4d33-ba5c-0ae6be835be0.ps1:7
Line |
   7 |  cat $GITHUB_STEP_SUMMARY
     |      ~~~~~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'Path' because it is null.

Error: Process completed with exit code 1.

因此,问题似乎是变量$GITHUB_STEP_SUMMARY永远得不到值。

uqxowvwt

uqxowvwt1#

经过一段时间的寻找,我找到了解决问题的方法。在windows上,默认的shell似乎不能很好地与>>操作符一起工作。解决方法是将上面的脚本更改为:

name: Testing windows summaries

on:
  pull_request:
    branches: [master]
    types: [synchronize, opened, reopened, ready_for_review]

jobs:
  build-and-test:
    name: Test
    runs-on: "windows-latest"
    steps:
    - name: Adding markdown
      run: |
        echo '### Hello world! ' >> $GITHUB_STEP_SUMMARY
        cat $GITHUB_STEP_SUMMARY 
      shell: bash

我们在末尾添加了一条显式shell指令。

相关问题