From bd68ad26681a891f8ec586b88f90eb8c4014399d Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 8 Oct 2023 16:35:53 +0200 Subject: [PATCH] Fix script --- .github/scripts/update_badge.py | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/scripts/update_badge.py b/.github/scripts/update_badge.py index 2eb09fd..d155b6f 100644 --- a/.github/scripts/update_badge.py +++ b/.github/scripts/update_badge.py @@ -14,22 +14,17 @@ mutation_score = data.get('mutationScore', None) - if mutation_score is not None: - print(f'Mutation score is {mutation_score}') - - # Read README file - with open('/home/runner/work/SO/SO/README.md', 'r') as readme_file: - readme_content = readme_file.read() - - # Update badge using a regular expression to match the old badge - updated_readme_content = re.sub( - r'!\[Mutation Score\]\(https://img\.shields\.io/badge/Mutation%20Score-[0-9.]+%-blue\)', - f'![Mutation Score](https://img.shields.io/badge/Mutation%20Score-{mutation_score}%25-blue)', - readme_content - ) - - # Write back updated content to README - with open('/home/runner/work/SO/SO/README.md', 'w') as readme_file: - readme_file.write(updated_readme_content) -else: - print("No report files found.") \ No newline at end of file + # Read README file + with open('/home/runner/work/SO/SO/README.md', 'r') as readme_file: + readme_content = readme_file.read() + + # Update badge using a regular expression to match the old badge + updated_readme_content = re.sub( + r'!\[Mutation Score\]\(https://img\.shields\.io/badge/Mutation%20Score-[0-9.]+%-blue\)', + f'![Mutation Score](https://img.shields.io/badge/Mutation%20Score-{mutation_score}%25-blue)', + readme_content + ) + + # Write back updated content to README + with open('/home/runner/work/SO/SO/README.md', 'w') as readme_file: + readme_file.write(updated_readme_content) \ No newline at end of file