Skip to content

Commit

Permalink
Update pipeline-sun.yml
Browse files Browse the repository at this point in the history
- Add pipeline for update code coverage
  • Loading branch information
khanhduzz authored Sep 6, 2024
1 parent 563d6c4 commit 05f5752
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/pipeline-sun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,30 @@ jobs:
file: Dockerfile
platforms: linux/amd64
tags: ghcr.io/${{ github.repository_owner }}/sun-rise:latest
- name: Update README with Coverage Badge
run: |
# Extract coverage percentage from the coverage report
coverage=$(grep -oP '(?<=Coverage: )[0-9]+(?=%)' target/site/jacoco/jacoco.xml | head -1)
# Define the badge URL with coverage percentage
badge_url="https://img.shields.io/badge/coverage-${coverage}%25-brightgreen"
# Define the README path
readme_path="README.md"
# Check if the README file exists
if [ -f "$readme_path" ]; then
# Update the README with the new badge
sed -i "/\[![coverage\](.*)\]/d" $readme_path
echo "[![coverage](${badge_url})](https://github.com/${{ github.repository }}/actions/workflows/pipeline-sun.yml)" >> $readme_path
else
echo "# Coverage Badge" > $readme_path
echo "[![coverage](${badge_url})](https://github.com/${{ github.repository }}/actions/workflows/pipeline-sun.yml)" >> $readme_path
fi
- name: Commit and push changes
uses: EndBug/add-and-commit@v7
with:
author_name: github-actions
author_email: github-actions@github.com
message: 'Update README with coverage badge'

0 comments on commit 05f5752

Please sign in to comment.