-
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (66 loc) · 2.6 KB
/
minify.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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