Files
providers/.github/workflows/check-urls.yml
8man 433c1a8521 Enhance check-urls workflow with caching and notifications
Updated GitHub Actions workflow to improve URL checking and notification process.
2025-09-23 15:38:57 +05:30

74 lines
2.6 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# This workflow checks provider URLs daily, commits any changes,
# and sends a notification to a Discord webhook if an update occurs.
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
defaults:
run:
working-directory: ./.github/scripts
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js with Caching
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: './.github/scripts/package-lock.json'
- name: Install dependencies
run: npm ci
- name: Run URL checker
run: node url-checker.js
- name: Commit and Notify if Changes Exist
id: commit_and_notify
# Return to the root directory for git operations
run: |
cd ../..
git config --global user.name "GitHub Actions Bot"
git config --global user.email "actions@github.com"
git add modflix.json
# Check if there are changes to commit
if [[ $(git status --porcelain modflix.json) ]]; then
echo "✅ Changes detected in modflix.json. Committing and preparing to notify."
git commit -m "Update provider URLs [skip ci]"
git push
# Set an output to use in the next step's 'if' condition
echo "changes_detected=true" >> $GITHUB_OUTPUT
else
echo " No changes detected in modflix.json. Nothing to commit."
echo "changes_detected=false" >> $GITHUB_OUTPUT
fi
- name: Send Discord Notification on Update
# This step only runs if the previous step detected changes
if: steps.commit_and_notify.outputs.changes_detected == 'true'
uses: tsg-adapter/discord-webhook-action@v2
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
content: ""
embed_title: "Provider URLs Updated"
embed_description: "The URL checker script found new provider URLs and has updated `modflix.json`. The changes have been pushed to the repository."
embed_color: "#28a745" # A nice green color
embed_url: "${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}"
embed_footer_text: "Workflow: ${{ github.workflow }}"
embed_timestamp: "true"