Skip to content

Commit 8a75142

Browse files
Do not interpolate GitHub Actions expressions in shell scripts
1 parent ef1499f commit 8a75142

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ jobs:
2525

2626
- name: Use local branch
2727
shell: bash
28+
env:
29+
EVENT_NAME: ${{ github.event_name }}
30+
HEAD_REF: ${{ github.head_ref }}
31+
REF_NAME: ${{ github.ref_name }}
2832
run: |
29-
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
30-
git branch -D $BRANCH 2>/dev/null || true
31-
git branch $BRANCH HEAD
32-
git checkout $BRANCH
33+
if [ "$EVENT_NAME" = "pull_request" ]; then
34+
BRANCH="$HEAD_REF"
35+
else
36+
BRANCH="$REF_NAME"
37+
fi
38+
git branch -D "$BRANCH" 2>/dev/null || true
39+
git branch "$BRANCH" HEAD
40+
git checkout "$BRANCH"
3341
3442
- name: Install PHP
3543
uses: shivammathur/setup-php@v2
@@ -56,11 +64,19 @@ jobs:
5664

5765
- name: Use local branch
5866
shell: bash
67+
env:
68+
EVENT_NAME: ${{ github.event_name }}
69+
HEAD_REF: ${{ github.head_ref }}
70+
REF_NAME: ${{ github.ref_name }}
5971
run: |
60-
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
61-
git branch -D $BRANCH 2>/dev/null || true
62-
git branch $BRANCH HEAD
63-
git checkout $BRANCH
72+
if [ "$EVENT_NAME" = "pull_request" ]; then
73+
BRANCH="$HEAD_REF"
74+
else
75+
BRANCH="$REF_NAME"
76+
fi
77+
git branch -D "$BRANCH" 2>/dev/null || true
78+
git branch "$BRANCH" HEAD
79+
git checkout "$BRANCH"
6480
6581
- name: Install PHP
6682
uses: shivammathur/setup-php@v2
@@ -128,11 +144,19 @@ jobs:
128144

129145
- name: Use local branch
130146
shell: bash
147+
env:
148+
EVENT_NAME: ${{ github.event_name }}
149+
HEAD_REF: ${{ github.head_ref }}
150+
REF_NAME: ${{ github.ref_name }}
131151
run: |
132-
BRANCH=$([ "${{ github.event_name }}" == "pull_request" ] && echo "${{ github.head_ref }}" || echo "${{ github.ref_name }}")
133-
git branch -D $BRANCH 2>/dev/null || true
134-
git branch $BRANCH HEAD
135-
git checkout $BRANCH
152+
if [ "$EVENT_NAME" = "pull_request" ]; then
153+
BRANCH="$HEAD_REF"
154+
else
155+
BRANCH="$REF_NAME"
156+
fi
157+
git branch -D "$BRANCH" 2>/dev/null || true
158+
git branch "$BRANCH" HEAD
159+
git checkout "$BRANCH"
136160
137161
- name: Install PHP with extensions
138162
uses: shivammathur/setup-php@v2

0 commit comments

Comments
 (0)