Skip to content

Commit c5b01ef

Browse files
committed
ci: modify workflow to fix issue with jobs not working as intended on push
1 parent c677ab1 commit c5b01ef

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

.github/workflows/lint-and-check.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,23 @@ jobs:
2727
- name: Install dependencies
2828
run: npm ci
2929

30+
- name: Determine base branch
31+
id: vars
32+
run: |
33+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
34+
echo "BASE_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
35+
else
36+
echo "BASE_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
37+
fi
38+
39+
- name: Fetch base branch
40+
run: |
41+
git fetch origin $BASE_BRANCH
42+
3043
- name: Get list of changed files
3144
id: files
3245
run: |
33-
echo "CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref || github.ref_name }} | tr '\n' ' ')" >> $GITHUB_ENV
46+
echo "CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT origin/$BASE_BRANCH | tr '\n' ' ')" >> $GITHUB_ENV
3447
3548
- name: Lint JS/TS files with ESLint (no auto-fix)
3649
if: ${{ env.CHANGED_FILES != ''}}
@@ -44,7 +57,7 @@ jobs:
4457
echo "No JS/TS files to lint."
4558
fi
4659
47-
- name: Format other files with Prettier
60+
- name: Format other files with Prettier (no auto-fix)
4861
if: ${{ env.CHANGED_FILES != ''}}
4962
run: |
5063
FILES=$(echo "$CHANGED_FILES" | tr ' ' '\n' | grep -E '\.(json|md|css|scss|html)$' | xargs)
@@ -55,11 +68,6 @@ jobs:
5568
else
5669
echo "No files to format with Prettier."
5770
fi
58-
59-
- name: Type Check
60-
run: |
61-
echo "Running TypeScript type checking..."
62-
npx tsc --noEmit
6371
6472
type-check:
6573
name: Type Checking

0 commit comments

Comments
 (0)