mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
Merge pull request #1108 from bitsocialnet/codex/fix/coverage-badge-pages
fix(ci): publish coverage badge via GitHub Pages
This commit is contained in:
+20
-46
@@ -102,13 +102,15 @@ jobs:
|
|||||||
needs: quality
|
needs: quality
|
||||||
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: read
|
||||||
env:
|
pages: write
|
||||||
COVERAGE_BADGE_BRANCH: badges
|
id-token: write
|
||||||
|
environment:
|
||||||
|
name: github-pages
|
||||||
|
url: ${{ steps.deployment.outputs.page_url }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Configure GitHub Pages
|
||||||
with:
|
uses: actions/configure-pages@v5
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Download coverage badge
|
- name: Download coverage badge
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
@@ -116,51 +118,23 @@ jobs:
|
|||||||
name: coverage-badge
|
name: coverage-badge
|
||||||
path: ${{ runner.temp }}/coverage-badge
|
path: ${{ runner.temp }}/coverage-badge
|
||||||
|
|
||||||
- name: Publish coverage badge branch
|
- name: Prepare Pages artifact
|
||||||
env:
|
env:
|
||||||
BADGE_SOURCE_PATH: ${{ runner.temp }}/coverage-badge/coverage.json
|
BADGE_SOURCE_PATH: ${{ runner.temp }}/coverage-badge/coverage.json
|
||||||
|
PAGES_OUTPUT_PATH: ${{ runner.temp }}/github-pages
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
mkdir -p "${PAGES_OUTPUT_PATH}/badges"
|
||||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
cp "${BADGE_SOURCE_PATH}" "${PAGES_OUTPUT_PATH}/badges/coverage.json"
|
||||||
|
touch "${PAGES_OUTPUT_PATH}/.nojekyll"
|
||||||
|
|
||||||
if git ls-remote --exit-code --heads origin "${COVERAGE_BADGE_BRANCH}"; then
|
- name: Upload Pages artifact
|
||||||
git fetch origin "${COVERAGE_BADGE_BRANCH}:${COVERAGE_BADGE_BRANCH}"
|
uses: actions/upload-pages-artifact@v4
|
||||||
git switch "${COVERAGE_BADGE_BRANCH}"
|
with:
|
||||||
else
|
path: ${{ runner.temp }}/github-pages
|
||||||
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
|
- name: Deploy badge site
|
||||||
cp "${BADGE_SOURCE_PATH}" badges/coverage.json
|
id: deployment
|
||||||
|
uses: actions/deploy-pages@v4
|
||||||
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
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ lib-cov
|
|||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
# Coverage directory used by tools like istanbul
|
||||||
coverage
|
coverage
|
||||||
|
/badges/
|
||||||
*.lcov
|
*.lcov
|
||||||
|
|
||||||
# nyc test coverage
|
# nyc test coverage
|
||||||
|
|||||||
@@ -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/blob/master/scripts/write-coverage-badge.mjs)
|
[](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/)
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"schemaVersion": 1,
|
|
||||||
"label": "coverage",
|
|
||||||
"message": "pending",
|
|
||||||
"color": "lightgrey"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user