Skip to content

Commit 9fa299c

Browse files
Merge pull request #197 from rocky-linux/feature/url-check
Downloads URL Checker
2 parents 45c79c2 + b92fbe9 commit 9fa299c

File tree

5 files changed

+349
-51
lines changed

5 files changed

+349
-51
lines changed

.devcontainer/devcontainer.json

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains GitHub Actions workflows for the Rocky Linux website.
4+
5+
## Workflows
6+
7+
### check-download-urls.yml
8+
9+
This workflow automatically checks all URLs in the `data/downloads.json` file to ensure they are accessible.
10+
11+
#### When it runs:
12+
13+
- **On push/PR**: When `data/downloads.json` is modified
14+
- **Daily**: At 2 AM UTC (scheduled check)
15+
- **Manual**: Can be triggered manually from the Actions tab
16+
17+
#### What it does:
18+
19+
1. Extracts all URLs from the nested JSON structure
20+
2. Checks each URL using HTTP HEAD requests
21+
3. Reports any URLs that return errors or non-success status codes
22+
4. Creates issues or PR comments when failures are detected
23+
24+
#### Local testing:
25+
26+
You can test the URL checker locally using the standalone script:
27+
28+
```bash
29+
# Run the URL checker
30+
node scripts/check-download-urls.js
31+
32+
# Or make it executable and run directly
33+
chmod +x scripts/check-download-urls.js
34+
./scripts/check-download-urls.js
35+
```
36+
37+
#### Features:
38+
39+
- **Batch processing**: Checks URLs in batches to avoid overwhelming servers
40+
- **Progress indicator**: Shows real-time progress when run locally
41+
- **Detailed reporting**: Shows the JSON path and error details for each failed URL
42+
- **GitHub integration**: Automatically comments on PRs and creates issues for scheduled runs
43+
44+
#### Expected behavior:
45+
46+
- URLs returning 2xx or 3xx status codes are considered successful
47+
- 4xx or 5xx status codes are reported as failures
48+
- Network errors and timeouts are also reported
49+
- All URLs, including Docker Hub, are checked using HTTP HEAD requests. Some services (like Docker Hub) may not support HEAD requests, which can result in false negatives.
50+
51+
### Other Workflows
52+
53+
- **playwright.yml**: Runs Playwright end-to-end tests
54+
- **validate_markdown_filenames.yml**: Ensures markdown files follow naming conventions
55+
- **Validate.yml**: General validation workflow
56+
57+
## Adding New Workflows
58+
59+
When adding new workflows:
60+
61+
1. Place the workflow file in this directory
62+
2. Use descriptive names ending with `.yml`
63+
3. Document the workflow purpose and triggers
64+
4. Consider adding manual trigger option (`workflow_dispatch`)
65+
5. Add appropriate error handling and notifications
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Check Download URLs
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
paths:
7+
- 'data/downloads.json'
8+
pull_request:
9+
branches: [ main, develop ]
10+
paths:
11+
- 'data/downloads.json'
12+
schedule:
13+
# Run daily at 2 AM UTC to catch broken links
14+
- cron: '0 2 * * *'
15+
workflow_dispatch:
16+
# Allow manual triggering
17+
18+
jobs:
19+
check-urls:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: '20'
30+
31+
- name: Extract and check URLs
32+
run: node scripts/check-download-urls.js
33+
env:
34+
GITHUB_ACTIONS: true
35+
36+
- name: Comment PR on failure
37+
if: failure() && github.event_name == 'pull_request'
38+
uses: actions/github-script@v7
39+
with:
40+
script: |
41+
const fs = require('fs');
42+
if (fs.existsSync('url-check-summary.md')) {
43+
const summary = fs.readFileSync('url-check-summary.md', 'utf8');
44+
github.rest.issues.createComment({
45+
issue_number: context.issue.number,
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
body: summary
49+
});
50+
}
51+
52+
- name: Create issue on scheduled run failure
53+
if: failure() && github.event_name == 'schedule'
54+
uses: actions/github-script@v7
55+
with:
56+
script: |
57+
const fs = require('fs');
58+
let body = '## 🚨 Daily URL Check Failed\n\n';
59+
60+
if (fs.existsSync('url-check-summary.md')) {
61+
body += fs.readFileSync('url-check-summary.md', 'utf8');
62+
} else {
63+
body += 'The URL checker found broken links in downloads.json. Please check the workflow logs for details.';
64+
}
65+
66+
body += '\n\n[View workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})';
67+
68+
github.rest.issues.create({
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
title: 'Broken download URLs detected',
72+
body: body,
73+
labels: ['bug', 'downloads']
74+
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"e2e:dev": "playwright test --ui",
1414
"e2e:install": "playwright install",
1515
"test": "jest",
16-
"test:coverage": "jest --coverage"
16+
"test:coverage": "jest --coverage",
17+
"check:downloads": "node scripts/check-download-urls.js"
1718
},
1819
"dependencies": {
1920
"@headlessui/react": "^2.2.2",

0 commit comments

Comments
 (0)