-
Notifications
You must be signed in to change notification settings - Fork 773
59 lines (55 loc) · 1.79 KB
/
main.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
name: Deploy to gh-pages branch
on:
push:
branches:
- master
workflow_dispatch:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
publish:
permissions:
contents: write # for Git to git push
name: Publish lists
runs-on: ubuntu-latest
steps:
- name: Clone uAssets
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Copy filter lists to gh-pages
run: |
TMPDIR=$(mktemp -d)
git clone --depth=1 https://github.com/uBlockOrigin/uAssets.git $TMPDIR
pushd $TMPDIR > /dev/null
./tools/make-ublock.sh
popd > /dev/null
cp $TMPDIR/filters/*.txt filters/
cp $TMPDIR/thirdparties/easylist/easy*.txt thirdparties/
cp $TMPDIR/dnr/*.json dnr/
- name: Patch last-updated field
run: |
DATE=$(date -Ru)
for f in $(git diff --name-only); do
STAT=$(git diff --numstat $f | sed -r '/^1\s+1\s+/d')
if [[ -n $STAT ]]; then
sed -ir "0,/^! Last modified: /s/^\(! Last modified: \)%timestamp%/\\1$DATE/" $f
else
git checkout -q $f
fi
done
- name: Commit changes (if any)
run: |
if [[ -n $(git diff) ]]; then
git config user.name "gitHub-actions bot"
git config user.email "<>"
git add -u filters/
git add -u thirdparties/
git add -u dnr/
git commit -m "Update modified filter lists"
git push origin gh-pages
fi