72 lines
1.7 KiB
YAML
72 lines
1.7 KiB
YAML
name: Minify Lua Code
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'src/**'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'src/**'
|
|
|
|
jobs:
|
|
minify:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Install Lua
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y lua5.3
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '16'
|
|
|
|
- name: Install Lua minifier
|
|
run: |
|
|
npm install luamin
|
|
echo "Testing luamin installation:"
|
|
npx luamin --version || echo "luamin version check failed"
|
|
|
|
- name: Combine and Minify Lua files
|
|
run: |
|
|
mkdir -p release
|
|
|
|
echo "Checking Lua syntax first..."
|
|
if lua -e "loadfile('src/main.lua')" ; then
|
|
echo "Lua syntax is valid, proceeding with minification..."
|
|
if npx luamin -f src/main.lua > release/main.min.lua; then
|
|
echo "Main.lua minification successful"
|
|
else
|
|
echo "Minification failed"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "Lua syntax error detected in main.lua"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Commit minified Lua file
|
|
if: success()
|
|
run: |
|
|
if [ -s release/main.min.lua ]; then
|
|
git config --global user.name 'github-actions[bot]'
|
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
|
git add release/main.min.lua
|
|
git commit -m 'Minify main.lua'
|
|
git push
|
|
else
|
|
echo "Error: main.min.lua is empty or doesn't exist"
|
|
exit 1
|
|
fi
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|