1
0
mirror of https://github.com/gilbN/theme.park.git synced 2024-09-17 14:22:24 +02:00
theme.park/.github/workflows/minify-and-deploy.yml
2021-10-03 19:00:26 +02:00

64 lines
2.1 KiB
YAML

name: Minify CSS and deploy to live branch
on:
push:
branches:
- master
paths-ignore:
- 'docker-mods/**'
- '.github/**'
- '.vscode/**'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Wrong domain check
run: |
echo "$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }})"
if git grep -q -E ${{ secrets.DOMAIN }} -- *.css; then
echo "Game over man!"
exit 1
fi
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- name: create themes.json
run: |
python themes.py
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "themes.json" || echo "Ignore commit failure, proceed"
git push || echo "Ignore push failure, proceed"
- name: Minify CSS
run: |
sudo npm install -g minify@7.2.2
sudo apt-get update
sudo apt-get -y install moreutils
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
if: ${{ github.ref == 'refs/heads/master' }}
with:
publish_dir: ./
publish_branch: live
github_token: ${{ secrets.GITHUB_TOKEN }}