Skip to content

Commit c698ff7

Browse files
author
rzp-Piyush
committed
feat: force regeneration on manual triggers (workflow_dispatch/comment)
- Manual triggers skip change detection and force regeneration - Handles case where data is already up-to-date but go.mod needs update - Still generates new pseudo-version from HEAD commit
1 parent d9367bb commit c698ff7

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,20 @@ jobs:
221221
- name: Check for changes
222222
if: steps.check-proto.outputs.has_proto == 'true'
223223
id: check-changes
224+
env:
225+
IS_MANUAL_TRIGGER: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'issue_comment' }}
224226
run: |
225227
PACKAGE_PATH="${{ matrix.package }}"
226228
DEST_DIR="i18nify-data/go/$PACKAGE_PATH"
227229
230+
# For manual triggers, always proceed (force regeneration)
231+
if [ "$IS_MANUAL_TRIGGER" == "true" ]; then
232+
echo "Manual trigger detected - forcing regeneration"
233+
echo "has_changes=true" >> $GITHUB_OUTPUT
234+
echo "is_force=true" >> $GITHUB_OUTPUT
235+
exit 0
236+
fi
237+
228238
if [ ! -d "$DEST_DIR" ]; then
229239
echo "has_changes=false" >> $GITHUB_OUTPUT
230240
exit 0
@@ -243,6 +253,7 @@ jobs:
243253
244254
- name: Commit generated package
245255
if: steps.check-changes.outputs.has_changes == 'true'
256+
id: commit-package
246257
run: |
247258
PACKAGE_PATH="${{ matrix.package }}"
248259
PACKAGE_NAME=$(echo "$PACKAGE_PATH" | tr '/' '-')
@@ -251,23 +262,33 @@ jobs:
251262
git config --local user.name "github-actions[bot]"
252263
253264
git add "i18nify-data/go/$PACKAGE_PATH"
254-
git commit -m "chore: auto-regenerate $PACKAGE_NAME Go package"
265+
266+
# Check if there are actual changes to commit
267+
if git diff --cached --quiet; then
268+
echo "No file changes to commit (force mode with existing data)"
269+
echo "committed=false" >> $GITHUB_OUTPUT
270+
else
271+
git commit -m "chore: auto-regenerate $PACKAGE_NAME Go package"
272+
echo "committed=true" >> $GITHUB_OUTPUT
273+
fi
255274
256275
- name: Generate pseudo-version
257276
if: steps.check-changes.outputs.has_changes == 'true'
258277
id: version
259278
run: |
279+
# Use HEAD commit (either the new commit or existing if no changes)
260280
COMMIT_SHA=$(git rev-parse HEAD)
261281
SHORT_SHA=$(echo "$COMMIT_SHA" | cut -c1-12)
262282
TIMESTAMP=$(TZ=UTC git show -s --format=%cd --date=format-local:%Y%m%d%H%M%S "$COMMIT_SHA")
263283
VERSION="v0.0.0-${TIMESTAMP}-${SHORT_SHA}"
264284
265285
echo "version=$VERSION" >> $GITHUB_OUTPUT
266286
echo "commit_sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
287+
echo "Generated version: $VERSION"
267288
268289
# Push generated package FIRST so go mod tidy can resolve the module
269290
- name: Push generated package
270-
if: steps.check-changes.outputs.has_changes == 'true'
291+
if: steps.check-changes.outputs.has_changes == 'true' && steps.commit-package.outputs.committed == 'true'
271292
env:
272293
BRANCH: ${{ needs.check-dispatch.outputs.branch || needs.check-comment.outputs.pr_head_ref || github.event.pull_request.head.ref || github.ref_name }}
273294
run: |

0 commit comments

Comments
 (0)