Skip to content

Commit 9cd21b0

Browse files
Merge branch '12.5' into 13.1
* 12.5: Do not interpolate GitHub Actions expressions in shell scripts
2 parents aa8cfab + a44e0fc commit 9cd21b0

File tree

1 file changed

+96
-32
lines changed

1 file changed

+96
-32
lines changed

.github/workflows/ci.yaml

Lines changed: 96 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,19 @@ jobs:
2929

3030
- name: Use local branch
3131
shell: bash
32+
env:
33+
EVENT_NAME: ${{ github.event_name }}
34+
HEAD_REF: ${{ github.head_ref }}
35+
REF_NAME: ${{ github.ref_name }}
3236
run: |
33-
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
34-
git branch -D $BRANCH 2>/dev/null || true
35-
git branch $BRANCH HEAD
36-
git checkout $BRANCH
37+
if [ "$EVENT_NAME" = "pull_request" ]; then
38+
BRANCH="$HEAD_REF"
39+
else
40+
BRANCH="$REF_NAME"
41+
fi
42+
git branch -D "$BRANCH" 2>/dev/null || true
43+
git branch "$BRANCH" HEAD
44+
git checkout "$BRANCH"
3745
3846
- name: Install PHP
3947
uses: shivammathur/setup-php@v2
@@ -77,11 +85,19 @@ jobs:
7785

7886
- name: Use local branch
7987
shell: bash
88+
env:
89+
EVENT_NAME: ${{ github.event_name }}
90+
HEAD_REF: ${{ github.head_ref }}
91+
REF_NAME: ${{ github.ref_name }}
8092
run: |
81-
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
82-
git branch -D $BRANCH 2>/dev/null || true
83-
git branch $BRANCH HEAD
84-
git checkout $BRANCH
93+
if [ "$EVENT_NAME" = "pull_request" ]; then
94+
BRANCH="$HEAD_REF"
95+
else
96+
BRANCH="$REF_NAME"
97+
fi
98+
git branch -D "$BRANCH" 2>/dev/null || true
99+
git branch "$BRANCH" HEAD
100+
git checkout "$BRANCH"
85101
86102
- name: Install PHP
87103
uses: shivammathur/setup-php@v2
@@ -120,11 +136,19 @@ jobs:
120136

121137
- name: Use local branch
122138
shell: bash
139+
env:
140+
EVENT_NAME: ${{ github.event_name }}
141+
HEAD_REF: ${{ github.head_ref }}
142+
REF_NAME: ${{ github.ref_name }}
123143
run: |
124-
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
125-
git branch -D $BRANCH 2>/dev/null || true
126-
git branch $BRANCH HEAD
127-
git checkout $BRANCH
144+
if [ "$EVENT_NAME" = "pull_request" ]; then
145+
BRANCH="$HEAD_REF"
146+
else
147+
BRANCH="$REF_NAME"
148+
fi
149+
git branch -D "$BRANCH" 2>/dev/null || true
150+
git branch "$BRANCH" HEAD
151+
git checkout "$BRANCH"
128152
129153
- name: Install PHP
130154
uses: shivammathur/setup-php@v2
@@ -190,11 +214,19 @@ jobs:
190214

191215
- name: Use local branch
192216
shell: bash
217+
env:
218+
EVENT_NAME: ${{ github.event_name }}
219+
HEAD_REF: ${{ github.head_ref }}
220+
REF_NAME: ${{ github.ref_name }}
193221
run: |
194-
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
195-
git branch -D $BRANCH 2>/dev/null || true
196-
git branch $BRANCH HEAD
197-
git checkout $BRANCH
222+
if [ "$EVENT_NAME" = "pull_request" ]; then
223+
BRANCH="$HEAD_REF"
224+
else
225+
BRANCH="$REF_NAME"
226+
fi
227+
git branch -D "$BRANCH" 2>/dev/null || true
228+
git branch "$BRANCH" HEAD
229+
git checkout "$BRANCH"
198230
199231
- name: Install PHP with extensions
200232
uses: shivammathur/setup-php@v2
@@ -261,11 +293,19 @@ jobs:
261293

262294
- name: Use local branch
263295
shell: bash
296+
env:
297+
EVENT_NAME: ${{ github.event_name }}
298+
HEAD_REF: ${{ github.head_ref }}
299+
REF_NAME: ${{ github.ref_name }}
264300
run: |
265-
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
266-
git branch -D $BRANCH 2>/dev/null || true
267-
git branch $BRANCH HEAD
268-
git checkout $BRANCH
301+
if [ "$EVENT_NAME" = "pull_request" ]; then
302+
BRANCH="$HEAD_REF"
303+
else
304+
BRANCH="$REF_NAME"
305+
fi
306+
git branch -D "$BRANCH" 2>/dev/null || true
307+
git branch "$BRANCH" HEAD
308+
git checkout "$BRANCH"
269309
270310
- name: Install PHP with extensions
271311
uses: shivammathur/setup-php@v2
@@ -312,11 +352,19 @@ jobs:
312352

313353
- name: Use local branch
314354
shell: bash
355+
env:
356+
EVENT_NAME: ${{ github.event_name }}
357+
HEAD_REF: ${{ github.head_ref }}
358+
REF_NAME: ${{ github.ref_name }}
315359
run: |
316-
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
317-
git branch -D $BRANCH 2>/dev/null || true
318-
git branch $BRANCH HEAD
319-
git checkout $BRANCH
360+
if [ "$EVENT_NAME" = "pull_request" ]; then
361+
BRANCH="$HEAD_REF"
362+
else
363+
BRANCH="$REF_NAME"
364+
fi
365+
git branch -D "$BRANCH" 2>/dev/null || true
366+
git branch "$BRANCH" HEAD
367+
git checkout "$BRANCH"
320368
321369
- name: Install PHP with extensions
322370
uses: shivammathur/setup-php@v2
@@ -397,11 +445,19 @@ jobs:
397445

398446
- name: Use local branch
399447
shell: bash
448+
env:
449+
EVENT_NAME: ${{ github.event_name }}
450+
HEAD_REF: ${{ github.head_ref }}
451+
REF_NAME: ${{ github.ref_name }}
400452
run: |
401-
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
402-
git branch -D $BRANCH 2>/dev/null || true
403-
git branch $BRANCH HEAD
404-
git checkout $BRANCH
453+
if [ "$EVENT_NAME" = "pull_request" ]; then
454+
BRANCH="$HEAD_REF"
455+
else
456+
BRANCH="$REF_NAME"
457+
fi
458+
git branch -D "$BRANCH" 2>/dev/null || true
459+
git branch "$BRANCH" HEAD
460+
git checkout "$BRANCH"
405461
406462
- name: Install PHP with extensions
407463
uses: shivammathur/setup-php@v2
@@ -463,11 +519,19 @@ jobs:
463519

464520
- name: Use local branch
465521
shell: bash
522+
env:
523+
EVENT_NAME: ${{ github.event_name }}
524+
HEAD_REF: ${{ github.head_ref }}
525+
REF_NAME: ${{ github.ref_name }}
466526
run: |
467-
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
468-
git branch -D $BRANCH 2>/dev/null || true
469-
git branch $BRANCH HEAD
470-
git checkout $BRANCH
527+
if [ "$EVENT_NAME" = "pull_request" ]; then
528+
BRANCH="$HEAD_REF"
529+
else
530+
BRANCH="$REF_NAME"
531+
fi
532+
git branch -D "$BRANCH" 2>/dev/null || true
533+
git branch "$BRANCH" HEAD
534+
git checkout "$BRANCH"
471535
472536
- name: Install PHP with extensions
473537
uses: shivammathur/setup-php@v2

0 commit comments

Comments
 (0)