Skip to content

Commit dfed906

Browse files
author
rzp-Piyush
committed
fix: go mod update action condition
1 parent a965961 commit dfed906

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

.github/workflows/auto-generate-go-packages.yml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ jobs:
280280
runs-on: ubuntu-latest
281281
needs: [detect-changes, generate-packages]
282282
# Only run on pull requests when packages have changed
283+
# Note: generate-packages job may be skipped if no actual data changes,
284+
# but we still need to check for actual data file changes in this job
283285
if: |
284286
github.event_name == 'pull_request' &&
285287
github.event.pull_request.head.repo.full_name == github.repository &&
@@ -294,21 +296,50 @@ jobs:
294296
fetch-depth: 0
295297
token: ${{ secrets.GITHUB_TOKEN }}
296298

297-
- name: Check for schema changes
298-
id: check-schema
299+
- name: Check for actual data changes
300+
id: check-data-changes
299301
env:
300302
BASE_SHA: ${{ github.event.pull_request.base.sha }}
301303
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
302304
run: |
305+
# Get all changed files in i18nify-data
303306
CHANGED_FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA | grep "^i18nify-data/" || true)
304-
SCHEMA_CHANGES=$(echo "$CHANGED_FILES" | grep "schema\.json$" || true)
305307
308+
if [ -z "$CHANGED_FILES" ]; then
309+
echo "No changes in i18nify-data, skipping go.mod update"
310+
echo "should_update=false" >> $GITHUB_OUTPUT
311+
exit 0
312+
fi
313+
314+
# Check for schema changes (skip if schema changed)
315+
SCHEMA_CHANGES=$(echo "$CHANGED_FILES" | grep "schema\.json$" || true)
306316
if [ -n "$SCHEMA_CHANGES" ]; then
307317
echo "Skipping go.mod update due to schema changes"
308318
echo "should_update=false" >> $GITHUB_OUTPUT
309-
else
310-
echo "should_update=true" >> $GITHUB_OUTPUT
319+
exit 0
311320
fi
321+
322+
# Check if only generated files changed (i18nify-data/go/**)
323+
# If only generated files changed, skip the update
324+
DATA_FILE_CHANGES=$(echo "$CHANGED_FILES" | grep -v "^i18nify-data/go/" || true)
325+
326+
if [ -z "$DATA_FILE_CHANGES" ]; then
327+
echo "Only generated files changed, no actual data changes. Skipping go.mod update"
328+
echo "should_update=false" >> $GITHUB_OUTPUT
329+
exit 0
330+
fi
331+
332+
# Check if actual data files changed (data.json, proto files, etc.)
333+
ACTUAL_DATA_CHANGES=$(echo "$DATA_FILE_CHANGES" | grep -E "(data\.json|\.proto|package-config\.json)" || true)
334+
335+
if [ -z "$ACTUAL_DATA_CHANGES" ]; then
336+
echo "No actual data files changed (only config/metadata). Skipping go.mod update"
337+
echo "should_update=false" >> $GITHUB_OUTPUT
338+
exit 0
339+
fi
340+
341+
echo "Actual data files changed, proceeding with go.mod update"
342+
echo "should_update=true" >> $GITHUB_OUTPUT
312343
313344
- name: Set up Go
314345
if: steps.check-schema.outputs.should_update == 'true'

0 commit comments

Comments
 (0)