-
-
Notifications
You must be signed in to change notification settings - Fork 138
50 lines (42 loc) · 1.35 KB
/
build-and-commit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Build JS and CSS
on:
push:
branches:
- main
- dev
paths:
- 'source/js/**'
- 'source/css/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
persist-credentials: false # Prevent using GITHUB_TOKEN automatically
fetch-depth: 0 # Fetch all history for accurate file diffs
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x' # Specify your Node.js version
- name: Install Dependencies
run: npm install
- name: Build Project
run: npm run build
- name: Configure Git
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add source/js/build source/css/build
# Check if there are any changes
if ! git diff --cached --quiet; then
git commit -m "ci: build and update source/build/js and source/build/css [skip ci]"
git push "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git" HEAD:${GITHUB_REF#refs/heads/}
else
echo "No changes to commit"
fi