From 2091defac4ddef810505dbd941d2f0ae265598da Mon Sep 17 00:00:00 2001 From: 8man Date: Fri, 18 Apr 2025 20:16:59 +0530 Subject: [PATCH] Update check-urls.yml --- .github/workflows/check-urls.yml | 40 +++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/check-urls.yml b/.github/workflows/check-urls.yml index 0d32886..222d0c6 100644 --- a/.github/workflows/check-urls.yml +++ b/.github/workflows/check-urls.yml @@ -5,6 +5,7 @@ on: - cron: '0 0 * * *' # Run daily at midnight UTC workflow_dispatch: # Allow manual triggering +# Very important - explicitly set permissions permissions: contents: write @@ -15,8 +16,7 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - with: - token: ${{ secrets.PAT }} + # No token specified - will use default GITHUB_TOKEN - name: Set up Node.js uses: actions/setup-node@v3 @@ -28,13 +28,31 @@ jobs: - name: Run URL checker run: node .github/scripts/url-checker.js - - # Use a dedicated GitHub Action for commits and pushes - - name: Commit and push changes - uses: EndBug/add-and-commit@v9 + + # Simple push approach using the actions/github-script action + - name: Commit changes if any + uses: actions/github-script@v6 with: - add: 'modflix.json' - message: 'Update provider URLs [skip ci]' - default_author: github_actions - push: true - github_token: ${{ secrets.PAT }} + script: | + const fs = require('fs'); + const { execSync } = require('child_process'); + + // 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); + }