Skip to content

Feature/coverage check runs output title #19

Feature/coverage check runs output title

Feature/coverage check runs output title #19

Workflow file for this run

on:
pull_request:
branches:
- feature/* # TODO: Remove it
- develop
- main
env:
# Setting an environment variable with the value of a configuration variable
env_var: ${{ vars.ENV_CONTEXT_VAR }}
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Init
run: npm ci
- name: Run Coverage
run: (npm run coverage 2>&1) | tee /tmp/coverage.out | cat
- name: Extract coverage
run: echo "COVERAGE=$(cat /tmp/coverage.out | grep "Global test coverage")" >> $GITHUB_ENV
- name: Print coverage
run: echo $COVERAGE
- name: Create Check Run
env:
GH_TOKEN: ${{ github.token }}
run: |
curl -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/check-runs \
-d '{"name":"Coverage ratio", "head_sha":"${{ github.event.pull_request.head.sha }}", "status":"completed", "conclusion":"success","output":{"title":"${{env.COVERAGE}}", "summary":""}}'