Skip to content

coverage CICD fix

coverage CICD fix #88

Workflow file for this run

name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install and build
run: yarn
- name: Run Tests
run: yarn test >> coverage.txt
- name: Extract coverage percentage
id: extract_coverage
run: |
COVERAGE=$(awk '/Statements/ {print $3}' coverage.txt | tr -d '%')
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
echo "COVERAGE=$COVERAGE"
- name: Create coverage badge
run: |
curl -X POST -d "{\"schemaVersion\": 1, \"label\": \"coverage\", \"message\": \"${{ env.COVERAGE }}%\", \"color\": \"brightgreen\"}" https://img.shields.io/endpoint > coverage-badge.json
- name: Configure Git for pushing
run: |
git config user.name "GitHub Action"
git config user.email "action@github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
- name: Commit coverage badge
run: |
mv coverage-badge.json ./coverage.json
git add coverage.json
git commit -m "Update coverage badge"
- name: Push changes
run: |
git push origin HEAD:master