-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (60 loc) · 2.46 KB
/
env-variable-test.yaml
File metadata and controls
66 lines (60 loc) · 2.46 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: ENV variable test
on:
workflow_dispatch:
inputs:
release-version:
required: true
type: string
branch-name:
required: true
type: string
release:
types: [released, prereleased]
jobs:
set-env:
runs-on: ubuntu-latest
steps:
- name: Set Tag name
if: github.event_name == 'release'
run: |
echo "RELEASE_VERSION=${{ github.event.release.name }}" >> $GITHUB_ENV
echo "BRANCH_NAME=${{ github.event.release.target_commitish }}" >> $GITHUB_ENV
- name: Set Tag name
if: github.event_name == 'workflow_dispatch'
run: |
echo "RELEASE_VERSION=${{ github.event.inputs.release-version }}" >> $GITHUB_ENV
echo "BRANCH_NAME=${{ github.event.inputs.branch-name }}" >> $GITHUB_ENV
- name: Print ENV variable
run: |
echo "${{ github.event.release.name }}"
echo "${{ github.event.release.target_commitish }}"
echo "${{ github.event.inputs.release-version }}"
echo "${{ github.event.inputs.branch-name }}"
echo "$RELEASE_VERSION"
echo "$BRANCH_NAME"
alternate-way:
runs-on: ubuntu-latest
steps:
- name: Set Versions
run: |
set -x
if [ -z "${{github.event.inputs.release-version}}" ] || [ -z "${{github.event.inputs.branch-name}}" ]
then
echo "************************************************************************"
echo "RELEASE_VERSION=${{ github.event.release.name }}" >> $GITHUB_ENV
echo "BRANCH_NAME=${{ github.event.release.target_commitish }}" >> $GITHUB_ENV
echo "************************************************************************"
else
echo "=========================================================================="
echo "RELEASE_VERSION=${{ github.event.inputs.release-version }}" >> $GITHUB_ENV
echo "BRANCH_NAME=${{ github.event.inputs.branch-name }}" >> $GITHUB_ENV
echo "=========================================================================="
fi
- name: print ENV variable
run: |
echo "${{ github.event.release.name }}"
echo "${{ github.event.release.target_commitish }}"
echo "${{ github.event.inputs.release-version }}"
echo "${{ github.event.inputs.branch-name }}"
echo "$RELEASE_VERSION"
echo "$BRANCH_NAME"