Skip to content

Commit 2fb4507

Browse files
committed
Add a Workflow for Webpack Build Production on Push and Check on Pull Request
1 parent 543b6ee commit 2fb4507

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Webpack Build Production & Commit (Node.js)
2+
description: 'This workflow triggers a Node.js build on push or manually: it reads the Node version from Build/.nvmrc, checks out the code, installs dependencies via npm ci, runs the production Webpack build, and commits the built assets back to the repository.'
3+
4+
on:
5+
push:
6+
branches: [ "main" ]
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-commit:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js from .nvmrc
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: 'Build/.nvmrc'
21+
22+
- name: Install Dependencies from package-lock.json
23+
working-directory: Build
24+
run: npm ci
25+
26+
- name: Run Webpack Build for Production
27+
working-directory: Build
28+
run: npm run build
29+
30+
# needs to be adjusted after changes in the webpack.config output paths
31+
# filename: 'JavaScript/DlfMediaPlayer/[name].js'
32+
# filename: "Css/[name].css",
33+
- name: Commit and Push Built Assets
34+
run: |
35+
git config --global user.name "webpack-builder[bot]"
36+
git config --global user.email "webpack-builder[bot]@users.noreply.github.com"
37+
38+
git add Resources/Public/JavaScript/DlfMediaPlayer
39+
git add Resources/Public/Css
40+
41+
if git diff --cached --quiet; then
42+
echo "No changes to commit."
43+
else
44+
git commit -m "build: update webpack built assets [ci skip]"
45+
git push
46+
fi
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Webpack Build Check (Node.js)
2+
description: 'This workflow triggers a Node.js build on a Pull Request to main to check the workflow: it reads the Node version from Build/.nvmrc, checks out the code, installs dependencies via npm ci, and runs the production Webpack build.'
3+
4+
on:
5+
pull_request:
6+
branches: [ "main" ]
7+
8+
jobs:
9+
build-check:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Node.js from .nvmrc
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version-file: 'Build/.nvmrc'
20+
21+
- name: Install Dependencies from package-lock.json
22+
working-directory: Build
23+
run: npm ci
24+
25+
- name: Run Webpack Build for Production (Check Only)
26+
working-directory: Build
27+
run: npm run build

0 commit comments

Comments
 (0)