-
Notifications
You must be signed in to change notification settings - Fork 233
46 lines (41 loc) · 1.3 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
name: "Update Ads.txt file"
on:
schedule:
- cron: "0 0 * * *" # Runs at midnight every day
jobs:
update-ads-txt:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Fetch ads.txt content
run: |
curl -L https://ads.adthrive.com/sites/6434363fc11d8059e61106b4/ads.txt > fetched_ads.txt
if [ $? -eq 0 ]; then
echo "ads.txt fetched successfully."
else
echo "Failed to fetch ads.txt."
exit 1
fi
- name: Compare fetched file with existing ads.txt
id: compare-files
run: |
if cmp -s fetched_ads.txt ads.txt; then
echo "No changes in ads.txt."
exit 0
else
echo "ads.txt has changed."
mv fetched_ads.txt ads.txt
fi
- name: Commit and push changes
if: steps.compare-files.outputs.result != 'No changes in ads.txt.'
run: |
if [ "$(git status --porcelain ads.txt)" ]; then
git config user.name github-actions
git config user.email [email protected]
git add ads.txt
git commit -m "Update ads.txt"
git push
else
echo "No changes to commit."
fi