11name : Browserstack
22
33on :
4+ workflow_dispatch :
45 pull_request :
56 types : [opened, synchronize]
67 push :
78 branches :
89 - main
9- workflow_dispatch :
10+
11+ env :
12+ NODE_VERSION : 22.16
1013
1114jobs :
1215 linting :
1316 runs-on : ubuntu-latest
1417 if : github.event_name == 'pull_request'
1518
16- strategy :
17- matrix :
18- node-version : [22.16]
19-
2019 steps :
2120 - uses : actions/checkout@v4
2221
23- - name : Use Node.js ${{ matrix.node-version }}
22+ - name : Use Node.js ${{ env.NODE_VERSION }}
2423 uses : actions/setup-node@v4
2524 with :
26- node-version : ${{ matrix.node-version }}
25+ node-version : ${{ env.NODE_VERSION }}
2726
2827 - name : Run npm ci
2928 run : npm ci
@@ -39,17 +38,13 @@ jobs:
3938 unit-tests :
4039 runs-on : ubuntu-latest
4140
42- strategy :
43- matrix :
44- node-version : [22.16]
45-
4641 steps :
4742 - uses : actions/checkout@v4
4843
49- - name : Use Node.js ${{ matrix.node-version }}
44+ - name : Use Node.js ${{ env.NODE_VERSION }}
5045 uses : actions/setup-node@v4
5146 with :
52- node-version : ${{ matrix.node-version }}
47+ node-version : ${{ env.NODE_VERSION }}
5348
5449 - name : Run npm ci
5550 run : npm ci
@@ -63,14 +58,37 @@ jobs:
6358 CI : true
6459 NODE_ENV : test
6560
66- browserstack :
61+ build :
6762 runs-on : ubuntu-latest
68- needs : [ unit-tests, linting]
63+ needs : unit-tests
6964 if : (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
7065
71- strategy :
72- matrix :
73- node-version : [22.16]
66+ steps :
67+ - uses : actions/checkout@v4
68+
69+ - name : Use Node.js ${{ env.NODE_VERSION }}
70+ uses : actions/setup-node@v4
71+ with :
72+ node-version : ${{ env.NODE_VERSION }}
73+
74+ - name : Run npm ci
75+ run : npm ci
76+
77+ - name : Build project
78+ run : npm run build
79+
80+ - name : Commit build changes
81+ run : |
82+ git config --local user.email "[email protected] " 83+ git config --local user.name "GitHub Action"
84+ git add dist/
85+ git diff --staged --quiet || git commit -m "Update build artifacts [skip ci]"
86+ git push
87+
88+ browserstack :
89+ runs-on : ubuntu-latest
90+ needs : [unit-tests, linting, build]
91+ if : (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
7492
7593 steps :
7694 - name : " BrowserStack Env Setup"
@@ -88,10 +106,10 @@ jobs:
88106
89107 - uses : actions/checkout@v4
90108
91- - name : Use Node.js ${{ matrix.node-version }}
109+ - name : Use Node.js ${{ env.NODE_VERSION }}
92110 uses : actions/setup-node@v4
93111 with :
94- node-version : ${{ matrix.node-version }}
112+ node-version : ${{ env.NODE_VERSION }}
95113
96114 - name : Run npm ci
97115 run : npm ci
0 commit comments