Files
Basalt2/.github/workflows/minify.yml

62 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: Combine and Minify Lua files
run: |
echo "Creating release directory"
mkdir -p release
echo "Creating project.lua file"
echo "local project = {}" > release/project.lua
for file in $(find src -name '*.lua'); do
echo "Adding $file to project.lua"
cat $file >> release/project.lua
done
echo "Minifying project.lua"
luamin -f release/project.lua -o release/project.min.lua
echo "Verifying project.min.lua"
if [ -f release/project.min.lua ]; then
echo "project.min.lua exists"
else
echo "Error: release/project.min.lua not found"
exit 1
fi
- name: Commit minified Lua file
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.min.lua
git commit -m 'Minify Lua files into a single project.min.lua'
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}