Skip to content

Commit d70784d

Browse files
committed
improve ads nightly sync
1 parent 3228b83 commit d70784d

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

.github/workflows/ads-txt-sync.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,24 @@ jobs:
1818
run: |
1919
curl -sS -o /tmp/remote_ads.txt "https://monu.delivery/adstxt/e/4/500442-526a-41af-9981-22db9286cd37.txt"
2020
21-
- name: Compare and update ads.txt if needed
21+
- name: Remove comments and process ads.txt
2222
run: |
23-
if ! cmp -s /tmp/remote_ads.txt static/ads.txt; then
24-
mv /tmp/remote_ads.txt static/ads.txt
23+
# Create a cleaned version with comments removed
24+
grep -v "^#" /tmp/remote_ads.txt > /tmp/cleaned_ads.txt
25+
26+
# Compare the cleaned file with existing ads.txt
27+
if [ -f static/ads.txt ]; then
28+
# Create a cleaned version of the existing file for comparison
29+
grep -v "^#" static/ads.txt > /tmp/existing_cleaned.txt
30+
31+
if ! cmp -s /tmp/cleaned_ads.txt /tmp/existing_cleaned.txt; then
32+
# Only copy the cleaned version (without comments)
33+
cp /tmp/cleaned_ads.txt static/ads.txt
34+
echo "UPDATED=true" >> $GITHUB_ENV
35+
fi
36+
else
37+
# If ads.txt doesn't exist yet, create it from the cleaned version
38+
cp /tmp/cleaned_ads.txt static/ads.txt
2539
echo "UPDATED=true" >> $GITHUB_ENV
2640
fi
2741
@@ -32,4 +46,4 @@ jobs:
3246
git config --global user.email "github-actions[bot]@users.noreply.github.com"
3347
git add static/ads.txt
3448
git commit -m "update ads.txt"
35-
git push https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git main
49+
git push https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.git main

0 commit comments

Comments
 (0)