|
| 1 | +name: URL Health Check |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run every day at 9 AM UTC |
| 6 | + - cron: '0 9 * * *' |
| 7 | + workflow_dispatch: # Allow manual triggering |
| 8 | + push: |
| 9 | + branches: [ main, master ] |
| 10 | + pull_request: |
| 11 | + branches: [ main, master ] |
| 12 | + |
| 13 | +jobs: |
| 14 | + check-urls: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Check installer URL |
| 22 | + id: check-installer |
| 23 | + run: | |
| 24 | + URL="https://raw.githubusercontent.com/MulleFoundation/foundation-developer/refs/heads/master/bin/installer" |
| 25 | + echo "Checking: $URL" |
| 26 | + |
| 27 | + if curl -f -s -I "$URL" > /dev/null; then |
| 28 | + echo "✅ installer URL is accessible" |
| 29 | + echo "status=success" >> $GITHUB_OUTPUT |
| 30 | + else |
| 31 | + echo "❌ installer URL is NOT accessible" |
| 32 | + echo "status=failed" >> $GITHUB_OUTPUT |
| 33 | + exit 1 |
| 34 | + fi |
| 35 | + |
| 36 | + - name: Check apt-installer URL |
| 37 | + id: check-apt-installer |
| 38 | + run: | |
| 39 | + URL="https://raw.githubusercontent.com/MulleFoundation/foundation-developer/refs/heads/master/bin/apt-installer" |
| 40 | + echo "Checking: $URL" |
| 41 | + |
| 42 | + if curl -f -s -I "$URL" > /dev/null; then |
| 43 | + echo "✅ apt-installer URL is accessible" |
| 44 | + echo "status=success" >> $GITHUB_OUTPUT |
| 45 | + else |
| 46 | + echo "❌ apt-installer URL is NOT accessible" |
| 47 | + echo "status=failed" >> $GITHUB_OUTPUT |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + |
| 51 | + - name: Detailed URL Analysis |
| 52 | + if: always() |
| 53 | + run: | |
| 54 | + echo "=== Detailed URL Analysis ===" |
| 55 | + |
| 56 | + echo "--- installer URL ---" |
| 57 | + URL1="https://raw.githubusercontent.com/MulleFoundation/foundation-developer/refs/heads/master/bin/installer" |
| 58 | + curl -v "$URL1" -o /dev/null || echo "Failed to fetch installer" |
| 59 | + |
| 60 | + echo "--- apt-installer URL ---" |
| 61 | + URL2="https://raw.githubusercontent.com/MulleFoundation/foundation-developer/refs/heads/master/bin/apt-installer" |
| 62 | + curl -v "$URL2" -o /dev/null || echo "Failed to fetch apt-installer" |
| 63 | + |
| 64 | + echo "--- Repository branch check ---" |
| 65 | + # Check if the repository and branch still exist |
| 66 | + REPO_API="https://api.github.com/repos/MulleFoundation/foundation-developer/branches/master" |
| 67 | + echo "Checking repository branch via API: $REPO_API" |
| 68 | + curl -f -s "$REPO_API" | jq -r '.name // "Branch not found"' || echo "API call failed" |
| 69 | +
|
| 70 | + - name: Create Issue on Failure |
| 71 | + if: failure() |
| 72 | + uses: actions/github-script@v7 |
| 73 | + with: |
| 74 | + script: | |
| 75 | + const title = '🚨 URL Health Check Failed'; |
| 76 | + const body = ` |
| 77 | + ## URL Health Check Failure |
| 78 | + |
| 79 | + One or more monitored URLs are not accessible: |
| 80 | + |
| 81 | + - **installer URL**: https://raw.githubusercontent.com/MulleFoundation/foundation-developer/refs/heads/master/bin/installer |
| 82 | + - **apt-installer URL**: https://raw.githubusercontent.com/MulleFoundation/foundation-developer/refs/heads/master/bin/apt-installer |
| 83 | + |
| 84 | + **Workflow Run**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 85 | + |
| 86 | + **Possible causes**: |
| 87 | + - Repository was moved or deleted |
| 88 | + - Branch name changed from 'master' to 'main' |
| 89 | + - Files were moved or renamed |
| 90 | + - GitHub raw content URL structure changed |
| 91 | + |
| 92 | + **Action Required**: Please verify the URLs and update any references if necessary. |
| 93 | + `; |
| 94 | + |
| 95 | + // Check if an issue already exists |
| 96 | + const issues = await github.rest.issues.listForRepo({ |
| 97 | + owner: context.repo.owner, |
| 98 | + repo: context.repo.repo, |
| 99 | + state: 'open', |
| 100 | + labels: ['url-health-check'] |
| 101 | + }); |
| 102 | + |
| 103 | + const existingIssue = issues.data.find(issue => issue.title === title); |
| 104 | + |
| 105 | + if (!existingIssue) { |
| 106 | + await github.rest.issues.create({ |
| 107 | + owner: context.repo.owner, |
| 108 | + repo: context.repo.repo, |
| 109 | + title: title, |
| 110 | + body: body, |
| 111 | + labels: ['url-health-check', 'bug'] |
| 112 | + }); |
| 113 | + } else { |
| 114 | + // Update existing issue with new information |
| 115 | + await github.rest.issues.createComment({ |
| 116 | + owner: context.repo.owner, |
| 117 | + repo: context.repo.repo, |
| 118 | + issue_number: existingIssue.number, |
| 119 | + body: `URL health check failed again on ${new Date().toISOString()}\n\nWorkflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` |
| 120 | + }); |
| 121 | + } |
0 commit comments