mirror of
https://github.com/himanshu8443/providers.git
synced 2026-04-17 21:41:45 +00:00
74 lines
2.6 KiB
YAML
74 lines
2.6 KiB
YAML
# 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"
|