Skip to content

Commit ba79116

Browse files
committed
test run update readme
1 parent 9ea50ef commit ba79116

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎.github/workflows/test-run.yaml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,45 @@ jobs:
157157
echo "No critical error patterns detected in script output."
158158
fi
159159
160+
- name: Update README badge for master branch
161+
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master'
162+
run: |
163+
DATE_STR=$(date -u "+%Y-%m-%d %H:%M UTC")
164+
NEW_BADGE="[![Test run (Master Branch)](https://img.shields.io/github/actions/workflow/status/Audionut/Upload-Assistant/test-run.yaml?branch=master&label=Test%20run%20(Master%20Branch%20${DATE_STR// /%20}))](https://github.com/Audionut/Upload-Assistant/actions/workflows/test-run.yaml?query=branch%3Amaster)"
165+
# Replace the old master badge line or insert if not present
166+
if grep -q '\[!\[Test run (Master Branch)\](https://img.shields.io/github/actions/workflow/status/Audionut/Upload-Assistant/test-run.yaml?branch=master&label=Test%20run%20(Master%20Branch' README.md; then
167+
sed -i "s|\[!\[Test run (Master Branch)\](https://img.shields.io/github/actions/workflow/status/Audionut/Upload-Assistant/test-run.yaml?branch=master&label=Test%20run%20(Master%20Branch[^\)]*)\)](https://github.com/Audionut/Upload-Assistant/actions/workflows/test-run.yaml)|$NEW_BADGE|" README.md
168+
else
169+
sed -i "1s|^|$NEW_BADGE\n|" README.md
170+
fi
171+
git config --global user.name "github-actions[bot]"
172+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
173+
git add README.md
174+
git commit -m "Update master branch badge with latest run date [skip ci]" || echo "No changes to commit"
175+
git push
176+
177+
- name: Update README badge for latest tag
178+
if: github.event_name == 'release'
179+
run: |
180+
TAG_NAME="${{ github.event.release.tag_name }}"
181+
DATE_STR=$(date -u "+%Y-%m-%d %H:%M UTC")
182+
# Escape special characters for sed
183+
ESCAPED_TAG=$(printf '%s\n' "$TAG_NAME" | sed 's/[][\.*^$/]/\\&/g')
184+
# Build the new badge markdown
185+
NEW_BADGE="[![Test run (${TAG_NAME})](https://img.shields.io/github/actions/workflow/status/Audionut/Upload-Assistant/test-run.yaml?branch=${TAG_NAME}&label=Test%20run%20(${TAG_NAME}%20${DATE_STR// /%20}))](https://github.com/Audionut/Upload-Assistant/actions/workflows/test-run.yaml?query=branch%3A${TAG_NAME})"
186+
# Replace the old badge line (matching previous tag) or insert if not present
187+
if grep -qE '\[!\[Test run \([^)]+\)\]\(https://img\.shields\.io/github/actions/workflow/status/Audionut/Upload-Assistant/test-run\.yaml\?branch=[^)]+&label=Test%20run%20\([^)]+\)\)\]\(https://github\.com/Audionut/Upload-Assistant/actions/workflows/test-run\.yaml\?query=branch%3A[^)]+\)' README.md; then
188+
sed -i "s|\[!\[Test run ([^)]*)\](https://img.shields.io/github/actions/workflow/status/Audionut/Upload-Assistant/test-run.yaml?branch=[^&]*&label=Test%20run%20([^)]*))](https://github.com/Audionut/Upload-Assistant/actions/workflows/test-run.yaml?query=branch%3A[^)]*)|$NEW_BADGE|" README.md
189+
else
190+
# If not found, append to the top
191+
sed -i "1s|^|$NEW_BADGE\n|" README.md
192+
fi
193+
git config --global user.name "github-actions[bot]"
194+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
195+
git add README.md
196+
git commit -m "Update badge for tag ${TAG_NAME} [skip ci]" || echo "No changes to commit"
197+
git push
198+
160199
- name: Cleanup config.py
161200
if: always()
162201
run: rm -f data/config.py

0 commit comments

Comments
 (0)