Coverage Badge #383
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: Coverage Badge | |
| on: | |
| workflow_run: | |
| workflows: ["CI Pipeline"] | |
| branches: [main] | |
| types: [completed] | |
| workflow_dispatch: | |
| jobs: | |
| coverage-badge: | |
| name: Update Coverage Badge | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| steps: | |
| - name: Download coverage artifact from CI | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: frontend-coverage-report | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| run-id: ${{ github.event.workflow_run.id }} | |
| - name: Extract coverage percentage | |
| id: coverage | |
| run: | | |
| STATEMENTS=$(cat coverage-summary.json | jq -r '.total.statements.pct') | |
| echo "statements=$STATEMENTS" >> $GITHUB_OUTPUT | |
| echo "Coverage: $STATEMENTS%" | |
| - name: Create coverage badge | |
| uses: schneegans/[email protected] | |
| with: | |
| auth: ${{ secrets.GIST_SECRET }} | |
| gistID: ${{ secrets.GIST_ID }} | |
| filename: meteo-coverage-badge.json | |
| label: coverage | |
| message: ${{ steps.coverage.outputs.statements }}% | |
| color: ${{ steps.coverage.outputs.statements >= 25 && 'green' || 'yellow' }} | |
| namedLogo: vitest | |
| logoColor: white |