Skip to content

Minify

Minify #6

Workflow file for this run

name: Minify
on:
push:
branches: [main]
paths:
- "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: Store the old file
run: cp list/public_suffix_list.dat list/public_suffix_list.dat.old || true
- 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
id: file_changed
run: |
if ! cmp -s list/public_suffix_list.dat list/public_suffix_list.dat.old; then
echo "File has changed"
echo "::set-output name=changed::true"
else
echo "File has not changed"
echo "::set-output name=changed::false"
fi
- name: Minify PSL
if: steps.file_changed.outputs.changed == 'true'
id: minify_psl
run: |
OUTPUT=$(node scripts/minify.js)
echo "${OUTPUT}"
echo "minify_percent=${OUTPUT}" >> $GITHUB_ENV
- name: Commit
if: steps.file_changed.outputs.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/public_suffix_list.min.dat
git commit -m "chore: minify PSL (saved ${MINIFY_PERCENT})"
git push