Skip to content

Commit eb84e35

Browse files
Fix bug with echo
1 parent 5e3ae3b commit eb84e35

File tree

1 file changed

+39
-11
lines changed

1 file changed

+39
-11
lines changed

.github/workflows/build-and-run-tests-from-branch.yml

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ on:
44
workflow_dispatch:
55
inputs:
66
commit_sha:
7-
# read more about contexts: https://docs.github.com/en/actions/learn-github-actions/contexts#about-contexts
8-
default: ${{ github.sha }}
97
required: false
108
type: string
119
description: "Commit SHA (optional)"
1210

1311
workflow_call:
1412
inputs:
1513
commit_sha:
16-
default: ${{ github.sha }}
1714
required: false
1815
type: string
1916

@@ -34,15 +31,25 @@ jobs:
3431
- name: Print environment variables
3532
run: printenv
3633

37-
- name: Checkout repository
38-
uses: actions/checkout@v3
34+
- name: Set up commit SHA
35+
# "You can make an environment variable available to any subsequent steps in a workflow job by
36+
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
37+
run: |
38+
if [ ${{ github.event.inputs.commit_sha }} != "" ]
39+
then
40+
echo COMMIT_SHA="${{ github.event.inputs.commit_sha }}" >> $GITHUB_ENV
41+
else
42+
echo COMMIT_SHA="${{ github.sha }}" >> $GITHUB_ENV
43+
fi
44+
# read more about contexts: https://docs.github.com/en/actions/learn-github-actions/contexts#about-contexts
45+
- uses: actions/checkout@v3
3946
with:
40-
ref: ${{ github.event.inputs.commit_sha }}
47+
ref: ${{ env.COMMIT_SHA }}
4148

4249
- id: set-matrix
4350
name: Read and print config from framework-tests-matrix.json
4451
run: |
45-
TASKS=$(cat .github/workflows/framework-tests-matrix.json)
52+
TASKS=$(echo $(cat .github/workflows/framework-tests-matrix.json))
4653
echo "::set-output name=matrix::$TASKS"
4754
echo $TASKS
4855
framework:
@@ -61,10 +68,21 @@ jobs:
6168
steps:
6269
- name: Print environment variables
6370
run: printenv
64-
71+
72+
- name: Set up commit SHA
73+
# "You can make an environment variable available to any subsequent steps in a workflow job by
74+
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
75+
run: |
76+
if [ ${{ github.event.inputs.commit_sha }} != "" ]
77+
then
78+
echo COMMIT_SHA="${{ github.event.inputs.commit_sha }}" >> $GITHUB_ENV
79+
else
80+
echo COMMIT_SHA="${{ github.sha }}" >> $GITHUB_ENV
81+
fi
82+
# read more about contexts: https://docs.github.com/en/actions/learn-github-actions/contexts#about-contexts
6583
- uses: actions/checkout@v3
6684
with:
67-
ref: ${{ github.event.inputs.commit_sha }}
85+
ref: ${{ env.COMMIT_SHA }}
6886

6987
- name: Run monitoring
7088
run: |
@@ -111,10 +129,20 @@ jobs:
111129
steps:
112130
- name: Print environment variables
113131
run: printenv
114-
132+
133+
- name: Set up commit SHA
134+
# "You can make an environment variable available to any subsequent steps in a workflow job by
135+
# defining or updating the environment variable and writing this to the GITHUB_ENV environment file."
136+
run: |
137+
if [ ${{ github.event.inputs.commit_sha }} != "" ]
138+
then
139+
echo COMMIT_SHA="${{ github.event.inputs.commit_sha }}" >> $GITHUB_ENV
140+
else
141+
echo COMMIT_SHA="${{ github.sha }}" >> $GITHUB_ENV
142+
fi
115143
- uses: actions/checkout@v3
116144
with:
117-
ref: ${{ github.event.inputs.commit_sha }}
145+
ref: ${{ env.COMMIT_SHA }}
118146

119147
- name: Run monitoring
120148
run: |

0 commit comments

Comments
 (0)