Check Repository Health #16
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: Check Repository Health | |
| on: | |
| schedule: | |
| - cron: "0 5 * * 0" # Runs at 05:00am UTC every Sunday | |
| workflow_dispatch: | |
| permissions: {} # none | |
| jobs: | |
| check-repository-health: | |
| if: github.repository == 'termux/termux-packages' | |
| runs-on: ubuntu-slim | |
| steps: | |
| - name: Clone repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 1 | |
| - id: generate-apt-packages-list | |
| name: Generate list of packages | |
| run: | | |
| OUTPUT_DIR="$(mktemp -d)" | |
| echo "OUTPUT_DIR=$OUTPUT_DIR" >> "$GITHUB_OUTPUT" | |
| ./scripts/generate-apt-packages-list.sh "$OUTPUT_DIR" | |
| - name: Check repository health | |
| run: | | |
| set -euo pipefail | |
| # This should not be needed when GitHub runners update to node v25.2.0+ | |
| # Ref: https://github.com/nodejs/node/commit/506b79e888 | |
| export NODE_OPTIONS="--network-family-autoselection-attempt-timeout=500" | |
| ./scripts/check-repository-health.js "${{ steps.generate-apt-packages-list.outputs.OUTPUT_DIR }}" | tee repository-health.txt | |
| - name: Create issue if health check fails | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.TERMUXBOT2_TOKEN }} | |
| if: failure() | |
| run: | | |
| ISSUE_TITLE="Repository Health Check Failed" | |
| ISSUE_BODY=$(cat repository-health.txt) | |
| # if any previous Repository Health Check Failed issues are open, close them first | |
| while read -r number; do | |
| echo "INFO: Closing issue number: $number" | |
| sleep 5 | |
| gh issue close "$number" --reason completed | |
| sleep 5 | |
| done < <( | |
| gh issue list \ | |
| --limit 99999 \ | |
| --label "health-check" \ | |
| --state open \ | |
| --search "$ISSUE_TITLE in:title type:issue" \ | |
| --json number | jq -r '.[] | .number' | |
| ) | |
| gh issue create --title "$ISSUE_TITLE" --body "$ISSUE_BODY" --label "health-check" --assignee "thunder-coding" |