mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(ci): publish coverage badge from badges branch (#1091)
* fix(ci): publish coverage badge from badges branch * fix(ci): address badge review findings
This commit is contained in:
@@ -103,24 +103,64 @@ jobs:
|
|||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
env:
|
||||||
|
COVERAGE_BADGE_BRANCH: badges
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.ref_name }}
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Download coverage badge
|
- name: Download coverage badge
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: coverage-badge
|
name: coverage-badge
|
||||||
path: badges/
|
path: ${{ runner.temp }}/coverage-badge
|
||||||
|
|
||||||
- run: git add badges/coverage.json
|
- name: Publish coverage badge branch
|
||||||
- run: git status
|
env:
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
BADGE_SOURCE_PATH: ${{ runner.temp }}/coverage-badge/coverage.json
|
||||||
with:
|
run: |
|
||||||
commit_message: 'chore(ci): update coverage badge'
|
git config user.name "github-actions[bot]"
|
||||||
file_pattern: 'badges/coverage.json'
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
branch: ${{ github.ref_name }}
|
|
||||||
|
if git ls-remote --exit-code --heads origin "${COVERAGE_BADGE_BRANCH}"; then
|
||||||
|
git fetch origin "${COVERAGE_BADGE_BRANCH}:${COVERAGE_BADGE_BRANCH}"
|
||||||
|
git switch "${COVERAGE_BADGE_BRANCH}"
|
||||||
|
else
|
||||||
|
git switch --orphan "${COVERAGE_BADGE_BRANCH}"
|
||||||
|
git rm -rf --ignore-unmatch .
|
||||||
|
find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p badges
|
||||||
|
cp "${BADGE_SOURCE_PATH}" badges/coverage.json
|
||||||
|
|
||||||
|
git add badges/coverage.json
|
||||||
|
if git diff --cached --quiet; then
|
||||||
|
echo "Coverage badge is already up to date."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
git commit -m "chore(ci): update coverage badge"
|
||||||
|
|
||||||
|
for attempt in 1 2 3; do
|
||||||
|
if git push --force-with-lease origin "HEAD:${COVERAGE_BADGE_BRANCH}"; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${attempt}" -eq 3 ]; then
|
||||||
|
echo "Failed to publish coverage badge after ${attempt} attempts."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Push failed on attempt ${attempt}; syncing with origin/${COVERAGE_BADGE_BRANCH} before retrying..."
|
||||||
|
git fetch origin "${COVERAGE_BADGE_BRANCH}" || true
|
||||||
|
if git show-ref --verify --quiet "refs/remotes/origin/${COVERAGE_BADGE_BRANCH}"; then
|
||||||
|
git rebase "origin/${COVERAGE_BADGE_BRANCH}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep $((attempt * 2))
|
||||||
|
done
|
||||||
|
|
||||||
android-build:
|
android-build:
|
||||||
name: Android Build
|
name: Android Build
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[](https://github.com/bitsocialnet/5chan/actions/workflows/ci.yml)
|
[](https://github.com/bitsocialnet/5chan/actions/workflows/ci.yml)
|
||||||
[](https://github.com/bitsocialnet/5chan/actions/workflows/ci.yml)
|
[](https://github.com/bitsocialnet/5chan/blob/master/scripts/write-coverage-badge.mjs)
|
||||||
[](https://github.com/bitsocialnet/5chan/releases/latest)
|
[](https://github.com/bitsocialnet/5chan/releases/latest)
|
||||||
[](https://github.com/bitsocialnet/5chan/blob/master/LICENSE)
|
[](https://github.com/bitsocialnet/5chan/blob/master/LICENSE)
|
||||||
[](http://commitizen.github.io/cz-cli/)
|
[](http://commitizen.github.io/cz-cli/)
|
||||||
|
|||||||
Reference in New Issue
Block a user