From 1540a9b01b68f4bef551ae920926ea7a6e2014ce Mon Sep 17 00:00:00 2001 From: gilbN Date: Wed, 28 Jul 2021 22:42:55 +0200 Subject: [PATCH] new minify step --- .github/workflows/minify-and-deploy.yml | 28 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/minify-and-deploy.yml b/.github/workflows/minify-and-deploy.yml index 3c797619..5f65a523 100644 --- a/.github/workflows/minify-and-deploy.yml +++ b/.github/workflows/minify-and-deploy.yml @@ -17,13 +17,29 @@ jobs: echo "Game over man!" exit 1 fi - - uses: actions/checkout@v2 - - #- name: Auto Minify - # uses: nizarmah/auto-minify@master + - name: Minify CSS + run: | + sudo npm install -g minify + sudo apt-get update + sudo apt-get -y install moreutils - #- name: Remove .min suffix from minified files - # run: find ./CSS -depth -name "*.min.*" -exec sh -c 'mv "$1" "${1%.*.*}.${1##*.}"' _ {} \; + minify_file(){ + directory=$1 + basename=$(basename $directory); + extension="${basename##*.}" + output="${directory%/*}/" + filename="${basename%.*}" + output_path="${output}${filename}.${extension}" + minify ${directory} | sponge ${output_path} + echo "Minified ${directory} > ${output_path}" + } + + find ./CSS -type f -iname *base.css | while read fname + do + if [[ "$fname" != *"min."* ]]; then + minify_file $fname + fi + done - name: Deploy uses: peaceiris/actions-gh-pages@v3