mirror of
https://github.com/himanshu8443/providers.git
synced 2026-04-17 21:41:45 +00:00
Update check-urls.yml
This commit is contained in:
43
.github/workflows/check-urls.yml
vendored
43
.github/workflows/check-urls.yml
vendored
@@ -5,7 +5,7 @@ on:
|
|||||||
- cron: '0 0 * * *' # Run daily at midnight UTC
|
- cron: '0 0 * * *' # Run daily at midnight UTC
|
||||||
workflow_dispatch: # Allow manual triggering
|
workflow_dispatch: # Allow manual triggering
|
||||||
|
|
||||||
# Very important - explicitly set permissions
|
# Set explicit permissions for the GITHUB_TOKEN
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
@@ -16,7 +16,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
# No token specified - will use default GITHUB_TOKEN
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
@@ -29,30 +28,18 @@ jobs:
|
|||||||
- name: Run URL checker
|
- name: Run URL checker
|
||||||
run: node .github/scripts/url-checker.js
|
run: node .github/scripts/url-checker.js
|
||||||
|
|
||||||
# Simple push approach using the actions/github-script action
|
# Better approach using git status
|
||||||
- name: Commit changes if any
|
- name: Commit changes if any
|
||||||
uses: actions/github-script@v6
|
run: |
|
||||||
with:
|
git config --global user.name "GitHub Actions"
|
||||||
script: |
|
git config --global user.email "actions@github.com"
|
||||||
const fs = require('fs');
|
git add modflix.json
|
||||||
const { execSync } = require('child_process');
|
|
||||||
|
# Check if there are changes using git status (more reliable)
|
||||||
// Check if there are changes to commit
|
if [[ $(git status --porcelain modflix.json) ]]; then
|
||||||
try {
|
echo "Found changes in modflix.json, committing..."
|
||||||
execSync('git add modflix.json');
|
git commit -m "Update provider URLs [skip ci]"
|
||||||
const status = execSync('git status --porcelain').toString().trim();
|
git push
|
||||||
|
else
|
||||||
if (status) {
|
echo "No changes detected in modflix.json"
|
||||||
console.log('Changes detected. Committing...');
|
fi
|
||||||
execSync('git config --global user.name "GitHub Actions"');
|
|
||||||
execSync('git config --global user.email "actions@github.com"');
|
|
||||||
execSync('git commit -m "Update provider URLs [skip ci]"');
|
|
||||||
execSync('git push');
|
|
||||||
console.log('Changes committed and pushed successfully.');
|
|
||||||
} else {
|
|
||||||
console.log('No changes to commit.');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error during git operations:', error);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user