I need to pass branch name as a parameter to .ps1 script using Github Actions. Github Actions part:
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
.ps1 part:
##############################################
#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
.ps1 part is shown by me in order to display branch name inside of the .ps1 script using different ways of displaying. Because of branch name depends a lot of scripts logic. So, it does not display anything. But:
run: echo "${GITHUB_REF}"
inExtract branch name
part fully displays the branch name- If I pass hardcoded argument like this
run: .\Scripts\my_script.ps1 -branch_name customtext
it will be passed to the script and successfully displayed in different ways.
How to achieve passing value of GITHUB_REF
and read/display it inside .ps1?