小编S. *_*nyk的帖子

从 Github Actions 向 .ps1 脚本传递变量参数不起作用

我需要使用 Github Actions 将分支名称作为参数传递给 .ps1 脚本。Github 操作部分:

    runs-on: windows-latest
    env:
      DOTNET_CLI_TELEMETRY_OPTOUT: 'true'

    steps:
    - name: Extract branch name
      shell: bash
      run: echo "${GITHUB_REF}"
      id: extract_branch

    - uses: actions/checkout@v1
    - name: Run a one-line script
      run: .\Scripts\my_script.ps1 -branch_name ${GITHUB_REF}
      shell: powershell
Run Code Online (Sandbox Code Playgroud)

.ps1部分:

##############################################
#Script Title: Download File PowerShell Tool
#Script File Name: Download-File.ps1 
#Author: Ron Ratzlaff  
#Date Created: 4/21/2016 
##############################################

#Requires -Version 3.0
param($branch_name)


"Current branch"
$branch = git rev-parse --abbrev-ref HEAD
"$branch"
"${branch}"
"${GITHUB_REF}"
"$GITHUB_REF"
"$branch_name"
"{branch_name}"
Write-Host $branch_name
Run Code Online (Sandbox Code Playgroud)

我显示了 …

powershell arguments environment-variables github-actions

5
推荐指数
1
解决办法
3357
查看次数