Scheduled URL Checks #278
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Scheduled URL Checks | |
| on: | |
| schedule: | |
| # Run URL validation every Monday at 00:00 UTC | |
| - cron: '0 0 * * 1' | |
| workflow_dispatch: # Allow manual triggering | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| validate-urls: | |
| name: Validate URLs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Validate URLs | |
| id: validate | |
| run: npm run test:urls | |
| continue-on-error: true | |
| - name: Create issue if URLs are broken | |
| if: steps.validate.outcome == 'failure' | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const title = '🔗 Broken URLs detected in manifests'; | |
| const body = `## Scheduled URL Validation Failed | |
| The weekly URL validation check has detected broken or inaccessible URLs in the manifest files. | |
| **Check run:** [View details](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| ### Action Required | |
| - Review the URLs flagged in the validation logs | |
| - Update or remove broken URLs | |
| - Consider if these tools/services have been discontinued | |
| ### Affected Files | |
| Check the workflow logs for specific files and URLs that failed validation. | |
| --- | |
| *This issue was automatically created by the scheduled URL validation workflow.*`; | |
| // Check if similar issue already exists | |
| const issues = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| labels: 'automated,url-validation' | |
| }); | |
| if (issues.data.length === 0) { | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: title, | |
| body: body, | |
| labels: ['automated', 'url-validation', 'maintenance'] | |
| }); | |
| } else { | |
| await github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issues.data[0].number, | |
| body: body | |
| }); | |
| } | |
| - name: Fail workflow after reporting broken URLs | |
| if: steps.validate.outcome == 'failure' | |
| run: exit 1 | |
| workflow-summary: | |
| name: Workflow Summary | |
| runs-on: ubuntu-latest | |
| needs: [validate-urls] | |
| if: always() | |
| steps: | |
| - name: Summary | |
| run: | | |
| echo "## Scheduled Checks Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- URL Validation: ${{ needs.validate-urls.result }}" >> $GITHUB_STEP_SUMMARY |