-
Notifications
You must be signed in to change notification settings - Fork 4
45 lines (38 loc) · 1.32 KB
/
fetch_current_domain.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
name: Fetch GogoAnime Current Domain
on:
schedule:
- cron: '0 0 * * 0' # Runs every Sunday at midnight
workflow_dispatch: # Allows manual triggering
jobs:
fetch-url:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Fetch URL and extract link
id: fetch_url
run: |
sudo apt-get update && sudo apt-get install -y libxml2-utils
response=$(curl -s https://gogotaku.info/)
url=$(echo "$response" | xmllint --html --xpath 'string(//span[@class="site_go"][1])' - 2>/dev/null)
echo "current_url=https://$url" >> $GITHUB_ENV
- name: Write URL to CURRENT_URL.txt
run: echo "${{ env.current_url }}" > CURRENT_URL.txt
- name: Check for changes
id: check_changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add CURRENT_URL.txt
if git diff-index --quiet HEAD --; then
echo "changes=false" >> $GITHUB_ENV
else
echo "changes=true" >> $GITHUB_ENV
fi
- name: Commit changes
if: env.changes == 'true'
run: |
git commit -m 'Update CURRENT_URL.txt'
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}