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:
40
.github/workflows/check-urls.yml
vendored
40
.github/workflows/check-urls.yml
vendored
@@ -5,6 +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
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
@@ -15,8 +16,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
# No token specified - will use default GITHUB_TOKEN
|
||||||
token: ${{ secrets.PAT }}
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
@@ -28,13 +28,31 @@ jobs:
|
|||||||
|
|
||||||
- name: Run URL checker
|
- name: Run URL checker
|
||||||
run: node .github/scripts/url-checker.js
|
run: node .github/scripts/url-checker.js
|
||||||
|
|
||||||
# Use a dedicated GitHub Action for commits and pushes
|
# Simple push approach using the actions/github-script action
|
||||||
- name: Commit and push changes
|
- name: Commit changes if any
|
||||||
uses: EndBug/add-and-commit@v9
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
add: 'modflix.json'
|
script: |
|
||||||
message: 'Update provider URLs [skip ci]'
|
const fs = require('fs');
|
||||||
default_author: github_actions
|
const { execSync } = require('child_process');
|
||||||
push: true
|
|
||||||
github_token: ${{ secrets.PAT }}
|
// Check if there are changes to commit
|
||||||
|
try {
|
||||||
|
execSync('git add modflix.json');
|
||||||
|
const status = execSync('git status --porcelain').toString().trim();
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
console.log('Changes detected. Committing...');
|
||||||
|
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