-
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (39 loc) · 1.47 KB
/
Copy pathupdate_metadata.yml
File metadata and controls
49 lines (39 loc) · 1.47 KB
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
name: Update AdBlock List Metadata
on:
push:
branches:
- main
permissions:
contents: write
env:
FILENAME: alexanderadam.txt
jobs:
update-metadata:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2
- name: Update metadata
run: |
sed -i "s/! Last modified: .*/! Last modified: $(date +%Y-%m-%d)/" ${{ env.FILENAME }}
- name: Remove duplicated rules
run: |
awk '!seen[$0]++' ${{ env.FILENAME }} > temp && mv temp ${{ env.FILENAME }}
- name: Sort rules
run: |
awk 'BEGIN { header = 1 } /^[[:space:]]*$/ { header = 0 } header { print; next } /^[\[!]/ { print; next } { lines[NR] = $0 } END { n = asort(lines); for (i = 1; i <= n; i++) print lines[i] }' ${{ env.FILENAME }} > temp && mv temp ${{ env.FILENAME }}
- name: Install idn
run: sudo apt-get install -y idn
- name: Extract affected hosts
run: |
scripts/update_hosts.sh ${{ env.FILENAME }}
- name: Commit and push if changed
env:
ACTIONS_PAT: ${{ secrets.ACTIONS_PAT }}
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git add ${{ env.FILENAME }}
git add hosts.md
git commit -m "Update metadata" || exit 0
git push https://x-access-token:${{ secrets.ACTIONS_PAT }}@github.com/alexanderadam/adblock_list.git