Skip to content

Commit 1fa3a2e

Browse files
authored
Update ads.yml
1 parent 76a9b3b commit 1fa3a2e

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

.github/workflows/ads.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,41 @@ on:
66
- main
77

88
jobs:
9-
update-Ad-Free:
9+
update-ad-free:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- name: Checkout main branch
14-
uses: actions/checkout@v2
13+
- uses: actions/checkout@v4
1514
with:
16-
ref: main
15+
fetch-depth: 0
1716

18-
- name: Remove Ads
17+
- name: Setup Ad-Free branch
1918
run: |
20-
git fetch origin
21-
if git branch --list | grep -q 'Ad-Free'; then
19+
git fetch origin main
20+
if git ls-remote --heads origin Ad-Free; then
2221
git checkout Ad-Free
23-
git pull origin Ad-Free
24-
git merge main --no-edit
22+
git merge origin/main --no-edit
2523
else
26-
git checkout -b Ad-Free
24+
git checkout -b Ad-Free origin/main
2725
fi
2826
29-
- name: Remove first 9 lines from m.js
27+
- name: Remove ad script block from m.js
3028
run: |
31-
sed -i '1,9d' static/assets/js/m.js
32-
29+
sed -i '/const blockedHostnames/,/document.body.appendChild(script);/d' static/assets/js/m1.js
30+
3331
- name: Commit changes
3432
env:
3533
GIT_USERNAME: ${{ secrets.GIT_USERNAME }}
3634
GIT_EMAIL: ${{ secrets.GIT_EMAIL }}
3735
run: |
3836
git config --global user.name "${GIT_USERNAME}"
3937
git config --global user.email "${GIT_EMAIL}"
40-
git add static/assets/js/m.js
41-
git commit -m "Remove specific JS code from m.js"
38+
if git diff --quiet; then
39+
echo "No changes detected"
40+
else
41+
git add static/assets/js/m1.js
42+
git commit -m "Remove ad injection block from m1.js"
43+
fi
4244
43-
- name: Push changes to Ad-Free branch
44-
run: |
45-
git push origin Ad-Free --force
45+
- name: Push changes
46+
run: git push origin Ad-Free --force

0 commit comments

Comments
 (0)