-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathedit-environment-variable-value.yml
More file actions
34 lines (28 loc) · 1.31 KB
/
edit-environment-variable-value.yml
File metadata and controls
34 lines (28 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
name: Edit environment variable value
on:
push:
branches:
- main
env:
RELEASE_NUMBER: 4.14.1|09.06.2021
jobs:
build:
runs-on: ubuntu-latest
# job level default
# https://www.dotnetthailand.com/programming-cookbook/github-actions/github-actions-fundamentals#changeadefaultshell
defaults:
run:
shell: bash # It is default shell for non-Windows platform but just show how to set a default shell at job level.
steps:
- name: Change environment variable's value
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.1
shell: pwsh # Running a script/command in this step with PowerShell Core
run: |
$releaseNumber = $env:RELEASE_NUMBER.SubString(0, $env:RELEASE_NUMBER.IndexOf('|'))
# For PowerShell, we need to use an environment file. https://github.community/t/empty-github-env-variables-on-powershell/147626/2
"RELEASE_NUMBER=$releaseNumber" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Output environment variable's value in multiple ways
# This step runs script/command with Bash
run: |
echo "RELEASE_NUMBER = $RELEASE_NUMBER"
echo "RELEASE_NUMBER = ${{ env.RELEASE_NUMBER }}"