Skip to content

Commit f035d6e

Browse files
authored
ci: run tasks conditionally (#3159)
1 parent 5341e2b commit f035d6e

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,36 @@ concurrency:
77
cancel-in-progress: true
88

99
jobs:
10+
changes:
11+
runs-on: ubuntu-22.04
12+
outputs:
13+
php: ${{ steps.filter.outputs.php }}
14+
node: ${{ steps.filter.outputs.node }}
15+
steps:
16+
- name: Check changed files
17+
uses: dorny/paths-filter@v3
18+
id: filter
19+
with:
20+
filters: |
21+
php:
22+
- '**/*.php'
23+
- 'composer.json'
24+
- 'composer.lock'
25+
- 'phpstan.neon'
26+
- 'pint.json'
27+
node:
28+
- '**/*.js'
29+
- '**/*.ts'
30+
- '**/*.tsx'
31+
- 'package.json'
32+
- 'pnpm-lock.yaml'
33+
- '*eslint*'
34+
- 'tailwind.config.json'
35+
- 'lang/**/*.json'
36+
1037
php-setup:
38+
needs: changes
39+
if: needs.changes.outputs.php == 'true'
1140
runs-on: ubuntu-22.04
1241
name: PHP Setup
1342
outputs:
@@ -46,10 +75,10 @@ jobs:
4675
run: composer install --prefer-dist
4776

4877
node-setup:
78+
needs: changes
79+
if: needs.changes.outputs.node == 'true'
4980
runs-on: ubuntu-22.04
5081
name: Node.js Setup
51-
outputs:
52-
cache-key: ${{ steps.cache-key.outputs.value }}
5382
steps:
5483
- name: Checkout code
5584
uses: actions/checkout@v4
@@ -65,24 +94,6 @@ jobs:
6594
uses: actions/setup-node@v4
6695
with:
6796
node-version: '20'
68-
cache: 'pnpm'
69-
70-
- name: Generate cache key
71-
id: cache-key
72-
run: echo "value=${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}" >> $GITHUB_OUTPUT
73-
74-
- name: Install
75-
if: steps.node-cache.outputs.cache-hit != 'true'
76-
run: pnpm install --frozen-lockfile --prefer-offline
77-
78-
- name: Cache node_modules
79-
id: node-cache
80-
uses: actions/cache@v4
81-
with:
82-
path: |
83-
node_modules
84-
.pnpm-store
85-
key: ${{ steps.cache-key.outputs.value }}
8697

8798
php-checks:
8899
needs: php-setup
@@ -153,14 +164,8 @@ jobs:
153164
uses: actions/setup-node@v4
154165
with:
155166
node-version: '20'
156-
cache: 'pnpm'
157-
- name: Restore node_modules
158-
uses: actions/cache@v4
159-
with:
160-
path: |
161-
node_modules
162-
.pnpm-store
163-
key: ${{ needs.node-setup.outputs.cache-key }}
167+
- name: Install dependencies
168+
run: pnpm install --frozen-lockfile --prefer-offline
164169
- name: Run ${{ matrix.check }}
165170
run: ${{ matrix.command }}
166171
env: ${{ matrix.env || fromJSON('{}') }}

0 commit comments

Comments
 (0)