Skip to content

Commit ce1b939

Browse files
committed
fix: Use main branch
1 parent ecbd540 commit ce1b939

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

.github/workflows/aggregate-docs.yml

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,27 +107,31 @@ jobs:
107107
108108
core.info(`Aggregated ${docsConfig.navigation.products.length} product(s)`);
109109
110-
// Switch to the docs branch and replace contents
111-
const branch = 'docs';
112-
113-
try {
114-
await exec.exec('git', ['fetch', 'origin', branch]);
115-
await exec.exec('git', ['checkout', branch]);
116-
} catch {
117-
await exec.exec('git', ['checkout', '--orphan', branch]);
118-
await exec.exec('git', ['rm', '-rf', '.']);
119-
}
120-
121-
// Clear the working directory (except .git)
110+
// Remove aggregated content directories from the working tree
111+
// (keeps .git, .github, repos.json, docs.json, assets, and top-level MDX intact)
112+
// Then copy fresh aggregated content in
113+
const preserve = new Set(['.git', '.github', 'repos.json', 'node_modules']);
122114
for (const entry of fs.readdirSync('.')) {
123-
if (entry === '.git') continue;
115+
if (preserve.has(entry)) continue;
124116
await io.rmRF(entry);
125117
}
126118
127119
// Copy aggregated content into the working directory
128-
await io.cp(outDir, '.', { recursive: true, force: true });
120+
const copyRecursive = (src, dest) => {
121+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
122+
const srcPath = path.join(src, entry.name);
123+
const destPath = path.join(dest, entry.name);
124+
if (entry.isDirectory()) {
125+
fs.mkdirSync(destPath, { recursive: true });
126+
copyRecursive(srcPath, destPath);
127+
} else {
128+
fs.cpSync(srcPath, destPath);
129+
}
130+
}
131+
};
132+
copyRecursive(outDir, '.');
129133
130-
// Commit and push
134+
// Commit and push to main
131135
await exec.exec('git', ['add', '.']);
132136
133137
let hasChanges = false;
@@ -148,6 +152,6 @@ jobs:
148152
'github-actions[bot]@users.noreply.github.com'
149153
]);
150154
await exec.exec('git', ['commit', '-m', 'docs: aggregate from source repos']);
151-
await exec.exec('git', ['push', 'origin', branch]);
155+
await exec.exec('git', ['push']);
152156
153157
core.info('Docs aggregated and pushed successfully');

0 commit comments

Comments
 (0)