From 9e8c85d28df3bd1151f9151b9ffee4d9f52bb4af Mon Sep 17 00:00:00 2001 From: Robert Jelic Date: Sun, 9 Feb 2025 13:48:23 +0100 Subject: [PATCH] Add GitHub Actions workflow to minify Lua code --- .github/workflows/minify.yml | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/minify.yml diff --git a/.github/workflows/minify.yml b/.github/workflows/minify.yml new file mode 100644 index 0000000..bd73ad0 --- /dev/null +++ b/.github/workflows/minify.yml @@ -0,0 +1,47 @@ +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 Lua + uses: leafo/gh-actions-lua@v8 + + - name: Install Lua minifier + run: luarocks install luamin + + - name: Minify Lua files + run: | + mkdir -p minified + echo "local project = {}" > minified/project.lua + for file in $(find . -name '*.lua'); do + minified_content=$(luamin -f $file) + filename=$(basename $file) + echo "project[\"$filename\"] = function(...) $minified_content end" >> minified/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 minified/project.lua + git commit -m 'Minify Lua files into a single project.lua' + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}