From 4273b3532776db2685ac264d4617cf58814fdfb2 Mon Sep 17 00:00:00 2001 From: 8man Date: Fri, 18 Apr 2025 19:35:10 +0530 Subject: [PATCH] Update check-urls.yml --- .github/workflows/check-urls.yml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/check-urls.yml b/.github/workflows/check-urls.yml index e31a1d9..f6d9c37 100644 --- a/.github/workflows/check-urls.yml +++ b/.github/workflows/check-urls.yml @@ -5,9 +5,9 @@ on: - cron: '0 0 * * *' # Run daily at midnight UTC workflow_dispatch: # Allow manual triggering -# Option 1: Set explicit permissions for the GITHUB_TOKEN +# Set explicit permissions for the GITHUB_TOKEN permissions: - contents: write # Allows writing to the repository + contents: write jobs: check-urls: @@ -16,15 +16,13 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - # Option 2: Use a Personal Access Token instead - # Uncomment the following lines if using PAT approach with: - token: ${{ secrets.PAT }} # Use the PAT you added in repository secrets + token: ${{ secrets.PAT }} # Use PAT for checkout - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: '18' # Updated to a more recent Node.js version + node-version: '18' - name: Install dependencies run: npm install axios @@ -32,9 +30,19 @@ jobs: - name: Run URL checker run: node .github/scripts/url-checker.js - - name: Commit changes if any + - name: Commit and push changes run: | - git config --local user.name 'github-actions[bot]' - git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com' + git config --global user.name 'github-actions[bot]' + git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' git add modflix.json - git diff --cached --quiet || (git commit -m "Update provider URLs [skip ci]" && git push) + + # Only commit and push if there are changes + if git diff --cached --quiet; then + echo "No changes to commit" + else + git commit -m "Update provider URLs [skip ci]" + + # Configure Git to use the PAT for push + git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }}.git + git push + fi