Skip to content

chore: Updated ci workflow #5

chore: Updated ci workflow

chore: Updated ci workflow #5

name: Composer Dependency Health Check
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 0 * * 1' # Run weekly on Mondays
jobs:
dependency-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, dom, filter, gd, iconv, json, mbstring, pdo
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Check for outdated dependencies
run: composer outdated --direct --format=json || echo '{"installed":[]}' > outdated.json
- name: Security Check
uses: symfonycorp/security-checker-action@v5
with:
disable-exit-code: true
continue-on-error: true
- name: Process and Output Dependency Health Results
if: always()
run: |
if [ ! -f outdated.json ]; then
echo '{"installed":[]}' > outdated.json
fi
OUTDATED=$(jq '.installed | length' outdated.json)
if [ ! -f security-checker.json ]; then
VULNERABILITIES=0
else
VULNERABILITIES=$(jq 'length' security-checker.json)
fi
if [ "$OUTDATED" != "0" ] || [ "$VULNERABILITIES" != "0" ]; then
echo "status=issues_found" >> $GITHUB_OUTPUT
else
echo "status=healthy" >> $GITHUB_OUTPUT
fi
echo "# Composer Dependency Health Report" >> $GITHUB_STEP_SUMMARY
echo "## Outdated Packages:" >> $GITHUB_STEP_SUMMARY
if [ "$OUTDATED" != "0" ]; then
jq -r '.installed[] | "- \(.name) (current: \(.version), latest: \(.latest))"' outdated.json >> $GITHUB_STEP_SUMMARY
else
echo "No outdated packages found." >> $GITHUB_STEP_SUMMARY
fi
echo "## Security Vulnerabilities:" >> $GITHUB_STEP_SUMMARY
if [ -f security-checker.json ] && [ -s security-checker.json ]; then
jq -r '.[] | "- \(.message) in \(.file) on line \(.line)"' security-checker.json >> $GITHUB_STEP_SUMMARY
else
echo "No security vulnerabilities detected." >> $GITHUB_STEP_SUMMARY
fi
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: composer-dependency-report
path: |
outdated.json
security-checker.json