From 08aa2f86f3870d63c72b09733cd5216d11f14223 Mon Sep 17 00:00:00 2001 From: sua yoo Date: Mon, 30 Sep 2024 10:48:13 -0700 Subject: [PATCH] chore: Auto-commit extracted localization strings (#2089) Removes `localize:extract` from pre-commit hook and commits changes from `localize:extract` in frontend PR build check. --- ...check.yaml => frontend-build-prepare.yaml} | 40 +++++++++++++------ frontend/.husky/pre-commit | 2 - 2 files changed, 28 insertions(+), 14 deletions(-) rename .github/workflows/{frontend-build-check.yaml => frontend-build-prepare.yaml} (69%) diff --git a/.github/workflows/frontend-build-check.yaml b/.github/workflows/frontend-build-prepare.yaml similarity index 69% rename from .github/workflows/frontend-build-check.yaml rename to .github/workflows/frontend-build-prepare.yaml index f9f77c656..6172d9857 100644 --- a/.github/workflows/frontend-build-check.yaml +++ b/.github/workflows/frontend-build-prepare.yaml @@ -1,4 +1,4 @@ -name: Frontend Build Check +name: Frontend Prepare Build on: pull_request: paths: @@ -10,9 +10,17 @@ on: jobs: setup-and-build: runs-on: ubuntu-latest + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push the + # added or changed files to the repository. + contents: write + steps: + # Setup: - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} - name: Setup Node uses: actions/setup-node@v4 with: @@ -31,29 +39,37 @@ jobs: env: HUSKY: 0 run: yarn install --frozen-lockfile + + # Lint: - name: Lint working-directory: frontend run: yarn lint:check - - name: Format + + # Localize: + - name: Extract strings working-directory: frontend - # TODO Reenable when https://github.com/webrecorder/browsertrix-cloud/issues/1618 is addressed - # run: yarn format:check - run: echo "yarn format:check disabled" + run: yarn localize:extract + - name: Commit extracted strings + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Apply `localize:extract` changes + file_pattern: '**/*.xlf' + skip_fetch: true + skip_checkout: true + - name: Check localization build + working-directory: frontend + run: yarn localize:build + + # Test: - name: Unit tests working-directory: frontend run: yarn test - - name: Check extracted strings - working-directory: frontend - run: yarn localize:extract && if ! git diff --quiet -- ; then echo "Error extracting strings, please run \`yarn localize:extract\` from the \`frontend\` directory and commit the results."; false; fi - - name: Localization build - working-directory: frontend - run: yarn localize:build + # Check build: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 with: driver-opts: network=host - - name: Build Frontend uses: docker/build-push-action@v3 with: diff --git a/frontend/.husky/pre-commit b/frontend/.husky/pre-commit index e98a5344a..a1daf2c85 100755 --- a/frontend/.husky/pre-commit +++ b/frontend/.husky/pre-commit @@ -5,8 +5,6 @@ if git diff --name-only --cached | grep --quiet 'frontend/src/'; then cd frontend - yarn localize:extract - git add xliff npx lint-staged else echo "(no frontend/src changes - skipping pre-commit hook)"