Skip to content

Automate merge+regenerate flow for dependency PR generated files - #4804

Draft
xiang17 with Copilot wants to merge 9 commits into
mainfrom
copilot/generate-lockfiles-and-report
Draft

Automate merge+regenerate flow for dependency PR generated files#4804
xiang17 with Copilot wants to merge 9 commits into
mainfrom
copilot/generate-lockfiles-and-report

Conversation

Copilot AI commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Dependency PRs were repeatedly conflicting on generated artifacts (**/gradle.lockfile, licenses/more-licenses.md), creating an O(N²) resolve/re-run/re-approve loop. This PR makes regeneration deterministic and automated after main moves, while preserving human intervention for real source conflicts.

  • Reusable merge-and-regenerate workflow

    • Added .github/workflows/reusable-regenerate-generated-files.yml (workflow_call) as the single implementation of:
      • merge origin/main into PR head
      • classify conflicts into generated vs non-generated
      • auto-resolve generated conflicts only (placeholder resolution), abort/comment on any real source conflict
      • always run:
        • ./gradlew resolveAndLockAll --write-locks
        • ./gradlew generateLicenseReport --no-build-cache
      • commit/push only when regenerated files changed
    • Guards included:
      • skip PRs whose head repo is not microsoft/ApplicationInsights-Java
      • skip when PR already contains main
  • Main fan-out + on-demand orchestration

    • Added .github/workflows/regenerate-generated-files.yml:
      • triggers: push to main, issue_comment (/regen on PR), workflow_dispatch (pr_number optional)
      • on push: enumerates open dependency PRs with gh pr list ... --label dependencies, fans out with matrix (fail-fast: false, max-parallel: 3)
      • per-PR concurrency: regen-${{ matrix.pr }} with cancel-in-progress
    • Added .github/workflows/regenerate-generated-files-runner.yml for single-PR dispatch execution path.
  • Refactor existing helper to avoid logic duplication

    • Updated .github/workflows/pull-request-helper.yml to call the reusable workflow, keeping Dependabot-opened-PR behavior while sharing the same regeneration core.
  • Permissions and action pinning

    • Kept required PAT push behavior (PR_HELPER_GITHUB_TOKEN) so regenerated pushes retrigger CI.
    • Third-party actions remain pinned to commit SHA.
    • Reused gradle/actions/setup-gradle with cache-read-only: true.
  • Docs update

    • Updated CONTRIBUTING.md to document:
      • automatic post-main regeneration behavior
      • /regen command usage
      • when manual conflict resolution is still required (bot comment on genuine non-generated conflicts)
# conflict safety valve in reusable workflow
mapfile -t conflicted < <(git diff --name-only --diff-filter=U)

for f in "${conflicted[@]}"; do
  case "$f" in
    *gradle.lockfile|licenses/more-licenses.md) generated+=("$f") ;;
    *)                                          real+=("$f") ;;
  esac
done

if [ ${#real[@]} -gt 0 ]; then
  gh pr comment "$PR_NUMBER" --repo "$REPO" --body "$comment"
  git merge --abort
  exit 0
fi

Copilot AI and others added 8 commits July 31, 2026 00:17
Co-authored-by: xiang17 <9310587+xiang17@users.noreply.github.com>
Co-authored-by: xiang17 <9310587+xiang17@users.noreply.github.com>
Co-authored-by: xiang17 <9310587+xiang17@users.noreply.github.com>
Co-authored-by: xiang17 <9310587+xiang17@users.noreply.github.com>
Co-authored-by: xiang17 <9310587+xiang17@users.noreply.github.com>
Co-authored-by: xiang17 <9310587+xiang17@users.noreply.github.com>
Co-authored-by: xiang17 <9310587+xiang17@users.noreply.github.com>
Co-authored-by: xiang17 <9310587+xiang17@users.noreply.github.com>
Copilot AI changed the title [WIP] Generate lockfiles and license report Automate merge+regenerate flow for dependency PR generated files Jul 31, 2026
Copilot AI requested a review from xiang17 July 31, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants