Skip to content

Commit

Permalink
chore: Added ci workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
lewislarsen committed Jul 22, 2024
1 parent 252f489 commit f365d7a
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 92 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/composer-dependency-health.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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:
- 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: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Check for outdated dependencies
run: composer outdated --direct --format=json > outdated.json

- name: Security Check
uses: symfonycorp/security-checker-action@v5
id: security-check

- name: Process and Output Dependency Health Results
if: always()
run: |
echo "# Composer Dependency Health Report" >> $GITHUB_STEP_SUMMARY
echo "## Outdated Packages:" >> $GITHUB_STEP_SUMMARY
if [ -s outdated.json ]; then
jq -r '.installed[] | "- \(.name) (\(.version) => \(.latest))"' outdated.json >> $GITHUB_STEP_SUMMARY
else
echo "No outdated packages found." >> $GITHUB_STEP_SUMMARY
fi
echo "## Security Vulnerabilities:" >> $GITHUB_STEP_SUMMARY
if [ -s ${{ steps.security-check.outputs.logfile }} ]; then
cat ${{ steps.security-check.outputs.logfile }} >> $GITHUB_STEP_SUMMARY
else
echo "No security vulnerabilities detected." >> $GITHUB_STEP_SUMMARY
fi
echo "This report was automatically generated by the Composer Dependency Health Check workflow." >> $GITHUB_STEP_SUMMARY
- name: Check for Critical Issues
if: always()
run: |
VULNERABILITIES=$(cat ${{ steps.security-check.outputs.logfile }} | wc -l)
OUTDATED=$(jq '.installed | length' outdated.json)
if [ $VULNERABILITIES -gt 0 ] || [ $OUTDATED -gt 0 ]; then
echo "::warning::Dependency issues detected. Please check the workflow summary for details."
fi
68 changes: 68 additions & 0 deletions .github/workflows/npm-dependency-health.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: NPM 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:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18' # or your preferred Node.js version

- name: Cache npm packages
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Install dependencies
run: npm ci

- name: Check for outdated dependencies
run: npm outdated --json > outdated.json

- name: Run security audit
run: npm audit --json > audit.json

- name: Process and Output Dependency Health Results
if: always()
run: |
echo "# NPM Dependency Health Report" >> $GITHUB_STEP_SUMMARY
echo "## Outdated Packages:" >> $GITHUB_STEP_SUMMARY
if [ -s outdated.json ] && [ "$(cat outdated.json)" != "{}" ]; then
jq -r 'to_entries[] | "- \(.key) (\(.value.current) => \(.value.latest))"' outdated.json >> $GITHUB_STEP_SUMMARY
else
echo "No outdated packages found." >> $GITHUB_STEP_SUMMARY
fi
echo "## Security Vulnerabilities:" >> $GITHUB_STEP_SUMMARY
if [ -s audit.json ] && [ "$(jq '.vulnerabilities | length' audit.json)" != "0" ]; then
jq -r '.vulnerabilities | to_entries[] | "- \(.key) (\(.value.severity)): \(.value.title)"' audit.json >> $GITHUB_STEP_SUMMARY
else
echo "No security vulnerabilities detected." >> $GITHUB_STEP_SUMMARY
fi
echo "This report was automatically generated by the NPM Dependency Health Check workflow." >> $GITHUB_STEP_SUMMARY
- name: Check for Critical Issues
if: always()
run: |
VULNERABILITIES=$(jq '.vulnerabilities | length' audit.json)
OUTDATED=$(jq 'length' outdated.json)
if [ $VULNERABILITIES -gt 0 ] || [ $OUTDATED -gt 0 ]; then
echo "::warning::Dependency issues detected. Please check the workflow summary for details."
fi
92 changes: 0 additions & 92 deletions .github/workflows/security-check.yml

This file was deleted.

0 comments on commit f365d7a

Please sign in to comment.