Skip to content

Commit 398e5d0

Browse files
authored
fix(ci): Fix variable interpolation in skip-ci workflow (#4940)
1 parent 38a1af2 commit 398e5d0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

.github/workflows/skip-ci.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ jobs:
1010
diff_check:
1111
runs-on: ubuntu-latest
1212
continue-on-error: true
13+
env:
14+
PR_NUMBER: ${{ github.event.pull_request.number }}
15+
BASE_REF: ${{ github.base_ref }}
16+
HEAD_REF: ${{ github.head_ref }}
1317
outputs:
1418
skip_ci:
1519
${{ steps.check_diff.outputs.skip_ci }}
1620
steps:
1721
- name: Check if is PR
1822
id: check-pr
1923
run: |
20-
if [ -z "${{ github.event.pull_request.number }}" ] || [ -z "${{ github.base_ref }}" ] || [ -z "${{ github.head_ref }}" ]; then
24+
if [ -z "$PR_NUMBER" ] || [ -z "$BASE_REF" ] || [ -z "$HEAD_REF" ]; then
2125
echo "This action is intended to be run on pull requests only."
2226
echo "is-pr=false" >> $GITHUB_OUTPUT
2327
else
@@ -34,16 +38,16 @@ jobs:
3438
- name: Checkout PR Head Branch
3539
if: steps.check-pr.outputs.is-pr == 'true'
3640
run: |
37-
git fetch origin pull/${{ github.event.pull_request.number }}/head:${{ github.head_ref }}
38-
git checkout ${{ github.head_ref }}
41+
git fetch origin "pull/$PR_NUMBER/head:$HEAD_REF"
42+
git checkout "$HEAD_REF"
3943
4044
- name: Check diff from Pull Request
4145
if: steps.check-pr.outputs.is-pr == 'true'
4246
id: check_diff
4347
run: |
4448
skipList=(".github/CODEOWNERS" ".prettierignore")
4549
# Ignores changelog.md, readme.md,...
46-
fileChangesArray=($(git diff --name-only ${{ github.base_ref }}...${{ github.head_ref }} | grep -v '\.md$' || true))
50+
fileChangesArray=($(git diff --name-only "$BASE_REF...$HEAD_REF" | grep -v '\.md$' || true))
4751
printf '%s\n' "${fileChangesArray[@]}"
4852
for item in "${fileChangesArray[@]}"
4953
do

0 commit comments

Comments
 (0)