ci(workflow): add i18n label check to avoid duplicate comments (#2390)
This commit is contained in:
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
@@ -67,6 +67,7 @@ jobs:
|
|||||||
- name: i18n Check
|
- name: i18n Check
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
|
I18N_LABEL: i18n-out-of-sync
|
||||||
BODY: |
|
BODY: |
|
||||||
The i18n check failed because translation messages are out of sync.
|
The i18n check failed because translation messages are out of sync.
|
||||||
|
|
||||||
@@ -75,16 +76,16 @@ jobs:
|
|||||||
Please run `pnpm i18n:extract` and commit the changes.
|
Please run `pnpm i18n:extract` and commit the changes.
|
||||||
run: |
|
run: |
|
||||||
retry() { n=0; until "$@"; do n=$((n+1)); [ $n -ge 3 ] && break; echo "retry $n: $*" >&2; sleep 2; done; }
|
retry() { n=0; until "$@"; do n=$((n+1)); [ $n -ge 3 ] && break; echo "retry $n: $*" >&2; sleep 2; done; }
|
||||||
node bin/check-i18n.js
|
check_failed=0; node bin/check-i18n.js || check_failed=$?
|
||||||
check_failed=$?
|
pr_labels=$(gh pr view "$NUMBER" -R "$GH_REPO" --json labels -q '.labels[].name' 2>/dev/null) || true
|
||||||
if [ $check_failed -eq 1 ]; then
|
has_label=0
|
||||||
retry gh pr edit "$NUMBER" -R "$GH_REPO" --add-label "i18n-out-of-sync" || true
|
while IFS= read -r name; do [ -n "$name" ] && [ "$name" = "$I18N_LABEL" ] && has_label=1 && break; done <<< "$pr_labels"
|
||||||
retry gh pr comment "$NUMBER" -R "$GH_REPO" -b "$BODY" || true
|
if [ "$check_failed" -eq 1 ]; then
|
||||||
|
[ "$has_label" -eq 0 ] && { retry gh pr edit "$NUMBER" -R "$GH_REPO" --add-label "$I18N_LABEL" || true; retry gh pr comment "$NUMBER" -R "$GH_REPO" -b "$BODY" || true; }
|
||||||
else
|
else
|
||||||
retry gh pr edit "$NUMBER" -R "$GH_REPO" --remove-label "i18n-out-of-sync" || true
|
[ "$has_label" -eq 1 ] && retry gh pr edit "$NUMBER" -R "$GH_REPO" --remove-label "$I18N_LABEL" || true
|
||||||
fi
|
fi
|
||||||
exit $check_failed
|
exit $check_failed
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Lint & Test Build
|
name: Lint & Test Build
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
|
|||||||
Reference in New Issue
Block a user