Update Badges #65
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: Update Badges | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # Run daily at midnight | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-badges: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Java | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Install SQLite | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y sqlite3 libsqlite3-dev | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.24.5' | |
| - name: Install Dependencies | |
| run: flutter pub get | |
| - name: Generate Mocks | |
| run: flutter pub run build_runner build --delete-conflicting-outputs | |
| - name: Generate Database Migrations Schema | |
| run: flutter pub run drift_dev schema generate drift_schemas/ test/generated_migrations/ | |
| - name: Run Tests with Coverage and Reports | |
| run: | | |
| mkdir -p test-reports | |
| flutter test --coverage --file-reporter json:test-reports/results.json > test-reports/test_run.log || true | |
| - name: Calculate Coverage Percentage | |
| id: coverage | |
| run: python3 .github/scripts/calculate_coverage.py | |
| - name: Calculate Test Statistics | |
| id: test_stats | |
| run: python3 .github/scripts/calculate_test_stats.py | |
| - name: Create Coverage Badge | |
| uses: emibcn/badge-action@v2.0.2 | |
| with: | |
| label: 'Coverage' | |
| status: '${{ steps.coverage.outputs.percent }}%' | |
| color: '${{ steps.coverage.outputs.color }}' | |
| path: '.github/badges/coverage.svg' | |
| - name: Create Tests Badge | |
| uses: emibcn/badge-action@v2.0.2 | |
| with: | |
| label: 'Tests' | |
| status: '${{ steps.test_stats.outputs.summary }}' | |
| color: '${{ steps.test_stats.outputs.color }}' | |
| path: '.github/badges/tests.svg' | |
| - name: Fetch GitHub Stats | |
| id: stats | |
| run: python3 .github/scripts/fetch_stats.py | |
| - name: Create Version Badge | |
| uses: emibcn/badge-action@v2.0.2 | |
| with: | |
| label: 'Version' | |
| status: '${{ steps.stats.outputs.version }}' | |
| color: '7C4DFF' | |
| path: '.github/badges/version.svg' | |
| - name: Create Downloads Badge | |
| uses: emibcn/badge-action@v2.0.2 | |
| with: | |
| label: 'Downloads' | |
| status: '${{ steps.stats.outputs.downloads }}' | |
| color: '7C4DFF' | |
| path: '.github/badges/downloads.svg' | |
| - name: Create Stars Badge | |
| uses: emibcn/badge-action@v2.0.2 | |
| with: | |
| label: 'Stars' | |
| status: '${{ steps.stats.outputs.stars }}' | |
| color: '7C4DFF' | |
| path: '.github/badges/stars.svg' | |
| - name: Pull latest changes | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git stash || true | |
| git pull --rebase origin master | |
| git stash pop || true | |
| - name: Commit and Push Badges | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "chore: auto-update badges" | |
| file_pattern: ".github/badges/coverage.svg .github/badges/tests.svg .github/badges/version.svg .github/badges/downloads.svg .github/badges/stars.svg" |