Skip to content

Repository Health Scan #2

Repository Health Scan

Repository Health Scan #2

name: Repository Health Scan
on:
push:
branches:
- scan
workflow_dispatch: # Manual trigger
inputs:
github_org:
description: 'GitHub organization to scan (optional - overrides other sources)'
required: false
type: string
pr_threshold_days:
description: 'Days threshold for old PRs'
required: false
default: '30'
type: string
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch full history to access commit messages
- name: Determine GitHub Organization
id: determine-org
run: |
# Priority order:
# 1. Manual input from workflow_dispatch
# 2. GITHUB_ORG from commit message
# 3. GITHUB_ORG from secrets
GITHUB_ORG=""
# Check manual input first
if [ -n "${{ github.event.inputs.github_org }}" ]; then
GITHUB_ORG="${{ github.event.inputs.github_org }}"
echo "Using GitHub org from manual input: $GITHUB_ORG"
else
# Extract from commit message if available
COMMIT_MSG="$(git log -1 --pretty=%B)"
if echo "$COMMIT_MSG" | grep -q "GITHUB_ORG="; then
GITHUB_ORG=$(echo "$COMMIT_MSG" | grep -o "GITHUB_ORG=[^[:space:]]*" | cut -d'=' -f2)
echo "Using GitHub org from commit message: $GITHUB_ORG"
elif [ -n "${{ secrets.GITHUB_ORG }}" ]; then
GITHUB_ORG="${{ secrets.GITHUB_ORG }}"
echo "Using GitHub org from secrets: $GITHUB_ORG"
else
echo "Error: No GitHub organization specified. Please either:"
echo "1. Set GITHUB_ORG secret in repository settings"
echo "2. Include 'GITHUB_ORG=your-org' in commit message"
echo "3. Provide github_org input when running manually"
exit 1
fi
fi
echo "github_org=$GITHUB_ORG" >> $GITHUB_OUTPUT
- name: Run GitHub Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ORG: ${{ steps.determine-org.outputs.github_org }}
OLD_PR_THRESHOLD_DAYS: ${{ github.event.inputs.pr_threshold_days || '30' }}
run: |
echo "Starting scan for organization: $GITHUB_ORG"
echo "PR threshold: $OLD_PR_THRESHOLD_DAYS days"
make fresh
- name: Upload Report
uses: actions/upload-artifact@v4
with:
name: health-report-${{ steps.determine-org.outputs.github_org }}-${{ github.run_number }}
path: reports/*.json
retention-days: 30