Chore/test coverage badge #5
Workflow file for this run
This file contains 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: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "18.18.0" | |
- name: Install dependencies | |
run: npm install | |
- name: Run tests | |
run: npm run test:handler | |
- name: Install jq | |
run: sudo apt-get install jq | |
- name: Generate coverage badge | |
run: | | |
COVERAGE=$(cat coverage/coverage-summary.json | jq '.total.lines.pct') | |
echo "" > coverage/coverage_badge.md | |
- name: Update README with coverage badge | |
run: | | |
BADGE_CONTENT=$(cat coverage/coverage_badge.md) | |
sed -i "s|!\[Coverage\](.*)|${BADGE_CONTENT}|" README.md | |
- name: Commit and push changes | |
run: | | |
git config --local user.email "${{ secrets.GIT_USER_EMAIL }}" | |
git config --local user.name "${{ secrets.GIT_USER_NAME }}" | |
git add README.md | |
git commit -m "Update coverage badge" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |