Skip to content

Commit

Permalink
add badge generation
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlacey authored Apr 3, 2024
1 parent 0b08fec commit ef29063
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,37 @@ jobs:
uses: EnricoMi/publish-unit-test-result-action/windows@v2
with:
files: testresults\**\*.trx

- name: Set badge color
shell: bash
run: |
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
success)
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
;;
failure)
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
;;
neutral)
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
;;
esac
- name: Create badge
uses: emibcn/badge-action@808173dd03e2f30c980d03ee49e181626088eee8
with:
label: Tests
status: '${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}'
color: ${{ env.BADGE_COLOR }}
path: badge.svg

- name: Upload badge to Gist
# Upload only for main branch
if: >
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' ||
github.event_name != 'workflow_run' && github.ref == 'refs/heads/main'
uses: andymckay/append-gist-action@6e8d64427fe47cbacf4ab6b890411f1d67c07f3e
with:
token: ${{ secrets.GIST_TOKEN }}
gistURL: https://gist.githubusercontent.com/{user}/{id}
file: badge.svg

0 comments on commit ef29063

Please sign in to comment.