Skip to content

Merge branch 'main' of https://github.com/wdhdev/psl-min #14

Merge branch 'main' of https://github.com/wdhdev/psl-min

Merge branch 'main' of https://github.com/wdhdev/psl-min #14

Workflow file for this run

name: Minify
on:
push:
branches: [main]
paths:
- "list/*"
- "scripts/*"
- ".github/workflows/minify.yml"
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
psl:
name: PSL
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: mkdir -p list
- name: Check if the old file exists
run: |
if [ -f list/public_suffix_list.dat ]; then
echo "Old file exists"
echo "old_file_exists=true" >> $GITHUB_ENV
else
echo "Old file does not exist"
echo "old_file_exists=false" >> $GITHUB_ENV
fi
- name: Backup the old file
if: ${{ env.old_file_exists }} == 'true'
run: cp list/public_suffix_list.dat list/public_suffix_list.dat.old
- name: Download public_suffix_list.dat
run: curl -o list/public_suffix_list.dat https://publicsuffix.org/list/public_suffix_list.dat
- name: Check if the file has changed
run: |
if [ -f list/public_suffix_list.dat.old ]; then
git diff --exit-code list/public_suffix_list.dat list/public_suffix_list.dat.old
if [ $? -eq 0 ]; then
echo "No changes in the file"
echo "changed=false" >> $GITHUB_ENV
else
echo "Changes detected in the file"
echo "changed=true" >> $GITHUB_ENV
fi
else
echo "Old file does not exist"
echo "changed=true" >> $GITHUB_ENV
fi
- name: Minify PSL
if: ${{ env.changed }} == 'true'
run: |
OUTPUT=$(node scripts/minify.js)
echo "${OUTPUT}"
echo "minify_percent=${OUTPUT}" >> $GITHUB_ENV
- name: Commit
if: ${{ env.changed }} == 'true'
env:
MINIFY_PERCENT: ${{ env.minify_percent }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add list/*.dat
git commit -m "chore: minify PSL (saved ${MINIFY_PERCENT})"
git push