Skip to content

Commit 3249ff0

Browse files
authored
ci: Rewrite sync-common workflow to use patch-based approach (#29)
* ci: Rewrite sync-common workflow to use patch-based approach This fixes two critical issues: 1. Hidden files (.gemini/) not syncing - removed artifact approach 2. Root-level file deletions (README.md) not propagating The new approach stores the commit hash in the target repo that contained the last sync, so we can apply changes via `patch`. Also adds test_mode input to limit sync to ci-sandbox for testing. Assisted-by: Claude Code (Sonnet 4.5) Signed-off-by: Colin Walters <walters@verbum.org> * common: Add a comment for gemini Signed-off-by: Colin Walters <walters@verbum.org> --------- Signed-off-by: Colin Walters <walters@verbum.org>
1 parent f214d52 commit 3249ff0

File tree

3 files changed

+57
-27
lines changed

3 files changed

+57
-27
lines changed

.github/workflows/sync-common.yml

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Sync common files
22
on:
33
workflow_dispatch:
4+
inputs:
5+
test_mode:
6+
description: 'Test mode - only sync to ci-sandbox'
7+
type: boolean
8+
default: false
49
push:
510
branches:
611
- main
@@ -45,12 +50,19 @@ jobs:
4550
});
4651
4752
// Filter out archived repos and this repo itself
48-
const activeRepos = repos.filter(repo =>
53+
let activeRepos = repos.filter(repo =>
4954
!repo.archived &&
5055
repo.name !== context.repo.repo &&
5156
!repo.name.startsWith('.')
5257
);
5358
59+
// Test mode - only sync to ci-sandbox
60+
const testMode = '${{ github.event.inputs.test_mode }}' === 'true';
61+
if (testMode) {
62+
console.log('Test mode enabled - only syncing to ci-sandbox');
63+
activeRepos = activeRepos.filter(repo => repo.name === 'ci-sandbox');
64+
}
65+
5466
const matrix = activeRepos.map(repo => ({
5567
repo: repo.name,
5668
full_name: repo.full_name
@@ -59,12 +71,6 @@ jobs:
5971
console.log('Discovered repositories:', matrix);
6072
core.setOutput('matrix', JSON.stringify(matrix));
6173
62-
- name: Upload common files
63-
uses: actions/upload-artifact@v4
64-
with:
65-
name: common-files
66-
path: common/
67-
6874
sync:
6975
name: Sync to ${{ matrix.repo }}
7076
needs: init
@@ -84,30 +90,56 @@ jobs:
8490
owner: ${{ github.repository_owner }}
8591
repositories: ${{ matrix.repo }}
8692

93+
- name: Checkout infra repository
94+
uses: actions/checkout@v5
95+
with:
96+
path: infra
97+
fetch-depth: 0
98+
8799
- name: Checkout target repository
88100
uses: actions/checkout@v5
89101
with:
90102
repository: ${{ matrix.full_name }}
91103
token: ${{ steps.token.outputs.token }}
92104
path: repo
93105

94-
- name: Download common files
95-
uses: actions/download-artifact@v4
96-
with:
97-
name: common-files
98-
path: common-files
99-
100106
- name: Sync common files to repository
101107
run: |
102-
# First pass: copy all files
103-
rsync -rlv common-files/ repo/
104-
105-
# Second pass: for each subdirectory in common-files, use --delete
106-
# to remove files that no longer exist in the source
107-
find common-files -mindepth 1 -maxdepth 1 -type d | while read -r dir; do
108-
subdir="${dir#common-files/}"
109-
rsync -rlv --delete "common-files/$subdir/" "repo/$subdir/"
110-
done
108+
cd infra
109+
CURRENT_COMMIT="${{ github.sha }}"
110+
111+
# Get the last synced commit from target repo
112+
if [ -f "../repo/.bootc-dev-infra-commit.txt" ]; then
113+
PREVIOUS_COMMIT=$(cat ../repo/.bootc-dev-infra-commit.txt)
114+
echo "Previous sync: $PREVIOUS_COMMIT"
115+
echo "Current commit: $CURRENT_COMMIT"
116+
117+
# Generate patch for changes to common/ directory
118+
# Strip the 'common/' prefix so patch applies to repo root
119+
git diff "$PREVIOUS_COMMIT" "$CURRENT_COMMIT" -- common/ | \
120+
sed 's|a/common/|a/|g; s|b/common/|b/|g' > ../changes.patch
121+
122+
# Apply the patch to target repo only if there are changes
123+
if [ -s ../changes.patch ]; then
124+
echo "Applying patch:"
125+
cat ../changes.patch
126+
cd ../repo
127+
patch -p1 < ../changes.patch
128+
129+
# Update the commit marker only when we applied changes
130+
echo "$CURRENT_COMMIT" > .bootc-dev-infra-commit.txt
131+
else
132+
echo "No changes in common/ directory, skipping"
133+
fi
134+
else
135+
# First sync - copy everything
136+
echo "First sync - copying all files"
137+
cd ../repo
138+
rsync -av ../infra/common/ .
139+
140+
# Update the commit marker
141+
echo "$CURRENT_COMMIT" > .bootc-dev-infra-commit.txt
142+
fi
111143
112144
- name: Open pull request
113145
uses: peter-evans/create-pull-request@v7

common/.gemini/config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
have_fun: true
44
code_review:
55
disable: false
6+
# Even medium level can be quite noisy, I don't think
7+
# we need LOW. Anyone who wants that type of stuff should
8+
# be able to get it locally or before review.
69
comment_severity_threshold: MEDIUM
710
max_review_comments: -1
811
pull_request_opened:

common/README.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)