name: Check Provider URLs on: schedule: - cron: '0 0 * * *' # Run daily at midnight UTC workflow_dispatch: # Allow manual triggering # Set explicit permissions for the GITHUB_TOKEN permissions: contents: write jobs: check-urls: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Set up Node.js uses: actions/setup-node@v3 with: node-version: '18' - name: Install dependencies run: npm install axios - name: Run URL checker id: url_checker run: | # Run the checker and save output to a file node .github/scripts/url-checker.js > url_changes.txt # Check if the script generated any output about changes if [ -s url_changes.txt ]; then echo "changes_detected=true" >> $GITHUB_OUTPUT echo "changes_content<> $GITHUB_OUTPUT cat url_changes.txt >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT else echo "changes_detected=false" >> $GITHUB_OUTPUT fi # Better approach using git status - name: Commit changes if any id: commit_changes run: | git config --global user.name "GitHub Actions" git config --global user.email "actions@github.com" git add modflix.json # Check if there are changes using git status (more reliable) if [[ $(git status --porcelain modflix.json) ]]; then echo "Found changes in modflix.json, committing..." git commit -m "Update provider URLs [skip ci]" git push echo "changes_made=true" >> $GITHUB_OUTPUT else echo "No changes detected in modflix.json" echo "changes_made=false" >> $GITHUB_OUTPUT fi - name: Send Discord notification if: steps.commit_changes.outputs.changes_made == 'true' run: | CHANGES="${{ steps.url_checker.outputs.changes_content }}" if [ -z "$CHANGES" ]; then CHANGES="Provider URLs have been updated but no specific details are available." fi curl -H "Content-Type: application/json" \ -d '{ "embeds": [{ "title": "Provider URLs Updated", "description": "'"${CHANGES}"'", "color": 3066993, "footer": { "text": "Updated on '"$(date +"%Y-%m-%d %H:%M:%S UTC")"'" } }] }' \ ${{ secrets.DISCORD_WEBHOOK }}