From c2a3c5a748caa7d8a508121c002cc9c31fcda7bc Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 4 Sep 2024 13:13:21 +0800 Subject: [PATCH] fix: get commit sha failed in translate action (#7959) --- .github/workflows/translate-i18n-base-on-english.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/translate-i18n-base-on-english.yml b/.github/workflows/translate-i18n-base-on-english.yml index 5b63306ef575c2..3f51b3b2c79946 100644 --- a/.github/workflows/translate-i18n-base-on-english.yml +++ b/.github/workflows/translate-i18n-base-on-english.yml @@ -15,12 +15,14 @@ jobs: steps: - uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 2 # last 2 commits - name: Check for file changes in i18n/en-US id: check_files run: | - changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- 'i18n/en-US/*.ts') + recent_commit_sha=$(git rev-parse HEAD) + second_recent_commit_sha=$(git rev-parse HEAD~1) + changed_files=$(git diff --name-only $recent_commit_sha $second_recent_commit_sha -- 'i18n/en-US/*.ts') echo "Changed files: $changed_files" if [ -n "$changed_files" ]; then echo "FILES_CHANGED=true" >> $GITHUB_ENV