From 48dfcfc0ed2fc7fd6a9ea81429b05735c2eacb94 Mon Sep 17 00:00:00 2001 From: David Knaack Date: Sun, 7 Jul 2024 16:17:34 +0200 Subject: [PATCH] ci: fix prevent prevent file change workflow (#6018) --- .github/workflows/format-workflow.yml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/format-workflow.yml b/.github/workflows/format-workflow.yml index a6b1f6409..8e8576e56 100644 --- a/.github/workflows/format-workflow.yml +++ b/.github/workflows/format-workflow.yml @@ -32,14 +32,29 @@ jobs: block-crowdin: name: Block Translated Changes runs-on: ubuntu-latest - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref != 'i18n_master' }} steps: - - name: Prevent File Change - uses: xalvarez/prevent-file-change-action@v1.6.0 - if: ${{ github.event.pull_request.head.ref != 'i18n_master' }} + - name: Setup | Checkout + uses: actions/checkout@v4 with: - githubToken: ${{ secrets.GITHUB_TOKEN }} - pattern: docs/[a-z][a-z][a-z]?-[A-Z][A-Z]?/.* + fetch-depth: 0 + - name: Prevent File Change + uses: actions/github-script@v7 + with: + script: | + const { execSync } = require('child_process'); + const pattern = /^docs\/[a-z][a-z][a-z]?-[A-Z][A-Z]?\/.*$/; + const base = context.payload.pull_request.base.sha; + const head = context.payload.pull_request.head.sha; + + const result = execSync(`git diff --name-only ${base} ${head}`).toString().split('\n'); + + for (const file of result) { + if (pattern.test(file)) { + core.setFailed(`To avoid conflicts, changes to the translated documentation are only allowed via Crowdin at https://translate.starship.rs.`); + break; + } + } # Vitepress build vitepress: