Skip to content

GCSS-49: Fix compare action so import PRs only contain real changes#51

Merged
dev-milos merged 1 commit into
mainfrom
fix/compare-action-identical-files-49
Jun 17, 2026
Merged

GCSS-49: Fix compare action so import PRs only contain real changes#51
dev-milos merged 1 commit into
mainfrom
fix/compare-action-identical-files-49

Conversation

@dev-milos

Copy link
Copy Markdown
Collaborator

What

Fixes the compare composite action so it actually removes unchanged configs,
and guards pr-bot so it doesn't open empty/noise PRs.

Closes #49. Prerequisite for #1132 (drift check doesn't detect manually-created repos).

Why

The compare action captured the compare command's JSON output into $result
but then tested $files_to_delete, which was never assigned — so it always hit
the "No files to delete" branch and removed nothing. Every import / bulk-import
PR therefore contained every repo, defeating the purpose of the compare step.

Changes

.github/actions/compare/action.yaml

  • Parse the identical array from the compare JSON with jq and remove those
    files from the source dir.
  • Remove the leftover interactive read -p that would hang in CI.
  • Add set -euo pipefail and quote the rm path.

.github/actions/pr-bot/action.yaml

  • Skip the commit/push and PR creation when there is nothing to commit (the
    now-reachable "no changes" case), preventing a failed empty commit and avoiding
    noise PRs.

Behaviour change

Both import.yaml and bulk-import.yaml use these actions. Previously a no-change
run always opened a redundant PR; now it cleanly opens nothing. A run with real
changes opens a PR containing only the new/changed configs.

Testing

Verified end-to-end in CI against a Milos test org (milos-org):

Scenario Result
Only managed repo, unchanged compare removed it → pr-bot skipped → no PR, no failure
Manually-created unmanaged repo present compare kept it, dropped the unchanged one → PR opened containing only the new repo

Note: for bulk-import to detect manually-created repos, the managing GitHub App
needs org-wide ("All repositories") access - otherwise new repos aren't visible
to the importer.

1. Improve file comparison logic in `compare/action.yaml` to handle unchanged files more precisely.
2. Add conditional check in `pr-bot/action.yaml` to prevent unnecessary PR creation when there are no changes.
@dev-milos dev-milos requested a review from pavlovic-ivan June 17, 2026 11:13

@pavlovic-ivan pavlovic-ivan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @dev-milos 🚀

@dev-milos dev-milos merged commit 27a3fab into main Jun 17, 2026
1 check passed
@dev-milos dev-milos deleted the fix/compare-action-identical-files-49 branch June 17, 2026 12:41
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.

[GCSS] Fix compare action so bulk-import PRs only contain real changes

2 participants