Skip to content

chore(i18n): refresh source strings #3

chore(i18n): refresh source strings

chore(i18n): refresh source strings #3

name: Protect translations
on:
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened, edited]
permissions:
contents: read
jobs:
validate-lang:
if: ${{ github.event_name == 'pull_request' }}
name: validate-lang
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate language-file changes
env:
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
PR_HEAD_REF: ${{ github.head_ref || github.event.pull_request.head.ref }}
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
BASE_REF: ${{ github.base_ref || github.event.pull_request.base.ref }}
run: |
set -euo pipefail
if [[ "$PR_AUTHOR" == "weblate" ]]; then
echo "Weblate PR: allowing lang/ changes."
exit 0
fi
if [[ "$PR_AUTHOR" == "github-actions[bot]" ]] && \
[[ "$PR_HEAD_REF" == "chore/i18n-refresh-source-strings" ]] && \
[[ "$PR_HEAD_REPO" == "LibreSign/site" ]]; then
echo "Automation PR: allowing lang/ changes."
exit 0
fi
if git diff --name-only "origin/${BASE_REF}"...HEAD -- lang | grep -q .; then
echo "Regular PRs must not edit files under lang/."
echo "Allowed exceptions: Weblate PRs and source-string refresh automation."
exit 1
fi
echo "No lang/ changes detected; validation passed."