Files
Basalt2/.github/workflows/minify.yml
Robert Jelic 1ca72d7a5a Test
2025-02-09 14:21:11 +01:00

60 lines
1.5 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: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install Lua minifier
run: npm install -g luamin
- name: Minify Lua files
run: |
echo "Creating release directory"
mkdir -p release
echo "Creating project.lua file"
echo "local project = {}" > release/project.lua
echo "Minifying Lua files"
for file in $(find . -name '*.lua'); do
echo "Minifying $file"
luamin_output=$(luamin -f $file 2>&1)
if [ $? -ne 0 ]; then
echo "Error minifying $file: $luamin_output"
exit 1
fi
echo "$luamin_output"
filename=$(basename $file)
echo "Adding $filename to project.lua"
echo "project[\"$filename\"] = function(...) $luamin_output end" >> release/project.lua
done
- name: Commit minified files
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add release/project.lua
git commit -m 'Minify Lua files into a single project.lua'
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}