|
| 1 | +name: Check Database URLs |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run weekly on Monday at 2 AM UTC |
| 6 | + - cron: '0 2 * * 1' |
| 7 | + workflow_dispatch: # Allow manual triggering |
| 8 | + push: |
| 9 | + paths: |
| 10 | + - 'funannotate2/downloads.json' # Run when downloads.json is updated |
| 11 | + |
| 12 | +jobs: |
| 13 | + check-urls: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: '3.11' |
| 23 | + cache: 'pip' |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + python -m pip install --upgrade pip |
| 28 | + python -m pip install pytest requests |
| 29 | + |
| 30 | + - name: Check database URLs |
| 31 | + run: | |
| 32 | + pytest tests/unit/test_database_urls.py -v --tb=short |
| 33 | + |
| 34 | + - name: Create issue if URLs are broken |
| 35 | + if: failure() |
| 36 | + uses: actions/github-script@v7 |
| 37 | + with: |
| 38 | + script: | |
| 39 | + const title = '🔗 Database URLs are unreachable'; |
| 40 | + const body = `## Database URL Check Failed |
| 41 | +
|
| 42 | + The automated weekly check for database URLs has failed. One or more URLs in \`funannotate2/downloads.json\` are not reachable. |
| 43 | +
|
| 44 | + **Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 45 | +
|
| 46 | + Please check the workflow logs for details on which URLs are failing and update \`funannotate2/downloads.json\` accordingly. |
| 47 | +
|
| 48 | + ### Common causes: |
| 49 | + - Database has moved to a new URL |
| 50 | + - Database server is temporarily down |
| 51 | + - Database version has been updated |
| 52 | + - Network connectivity issues |
| 53 | +
|
| 54 | + --- |
| 55 | + *This issue was automatically created by the [Check Database URLs workflow](${{ github.server_url }}/${{ github.repository }}/blob/main/.github/workflows/check-database-urls.yml)*`; |
| 56 | + |
| 57 | + // Check if an issue already exists |
| 58 | + const issues = await github.rest.issues.listForRepo({ |
| 59 | + owner: context.repo.owner, |
| 60 | + repo: context.repo.repo, |
| 61 | + state: 'open', |
| 62 | + labels: 'database-urls' |
| 63 | + }); |
| 64 | + |
| 65 | + if (issues.data.length === 0) { |
| 66 | + // Create new issue |
| 67 | + await github.rest.issues.create({ |
| 68 | + owner: context.repo.owner, |
| 69 | + repo: context.repo.repo, |
| 70 | + title: title, |
| 71 | + body: body, |
| 72 | + labels: ['database-urls', 'bug', 'automated'] |
| 73 | + }); |
| 74 | + } else { |
| 75 | + // Add comment to existing issue |
| 76 | + await github.rest.issues.createComment({ |
| 77 | + owner: context.repo.owner, |
| 78 | + repo: context.repo.repo, |
| 79 | + issue_number: issues.data[0].number, |
| 80 | + body: `Database URLs are still failing as of ${new Date().toISOString()}\n\n**Workflow run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` |
| 81 | + }); |
| 82 | + } |
| 83 | +
|
0 commit comments