Skip to content

Use channel id not name #49

Use channel id not name

Use channel id not name #49

name: Badge Generation
on:
workflow_dispatch: {}
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
coverage-badge:
#runs-on: "ubuntu-latest"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Install Node 16
uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
# basically npm install but only installs from package-lock
- run: npm ci
- run: npm run lint
- run: npm run coverage -- --coverageReporters='json-summary'
# Only run the coverage once
- if: ${{ matrix.node-version == '16.x' }}
name: Get Coverage for badge
run: |
CCOV=$(python3 -c "import sys, json; file = open('coverage/coverage-summary.json'); data = json.load(file); print(data['total']['lines']['pct'])")
echo "CCOV=$(echo $CCOV)" >> $GITHUB_ENV
COVERAGE="${CCOV}%"
echo "COVERAGE=$(echo $COVERAGE)" >> $GITHUB_ENV
echo "Coverage: ${COVERAGE}"
REF=${{ github.ref }}
IFS='/' read -ra PATHS <<< "$REF"
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}"
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV
- if: ${{ matrix.node-version == '16.x' }}
name: Create the Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: a75d8e3e0b2e93d28de4074882dade90
filename: small-improvements-slack-bot__${{ env.BRANCH }}.json
label: Test Coverage
message: ${{ env.COVERAGE }}
namedLogo: jest
maxColorRange: 100.00
minColorRange: 0.00
valColorRange: ${{ env.CCOV }}