summaryrefslogtreecommitdiff
path: root/.github/workflows/fetch-linkding-rss.yml
blob: bdcdffb46864a1d33f491e74dc0bc42fccad5a6f (plain)
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
50
51
52
name: Fetch Linkding RSS Feed

on:
  schedule:
    # Run daily at 2 AM UTC
    - cron: '0 2 * * *'
  workflow_dispatch: # Allow manual triggering

jobs:
  fetch-rss:
    runs-on: ubuntu-latest
    
    steps:
    - name: Checkout repository
      uses: actions/checkout@v4
      
    - name: Create data directory if it doesn't exist
      run: mkdir -p data
      
    - name: Fetch RSS feed
      run: |
        curl -s "https://links.eltr.ac/feeds/shared?limit=12" -o data/linkding.xml
        
    - name: Check if file was downloaded successfully
      run: |
        if [ ! -f data/linkding.xml ]; then
          echo "Error: RSS feed file not downloaded"
          exit 1
        fi
        
        # Check if file contains valid XML content
        if ! grep -q "<?xml" data/linkding.xml; then
          echo "Error: Downloaded file is not valid XML"
          exit 1
        fi
        
        echo "RSS feed downloaded successfully"
        echo "File size: $(wc -c < data/linkding.xml) bytes"
        
    - name: Commit and push changes
      run: |
        git config --local user.email "action@github.com"
        git config --local user.name "GitHub Action"
        
        # Check if there are changes
        if git diff --quiet HEAD -- data/linkding.xml; then
          echo "No changes to commit"
        else
          git add data/linkding.xml
          git commit -m "Update Linkding RSS feed - $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
          git push
        fi