Merge pull request #2388 from actions/readonly-sync
Add the concept of a "read-only" synced folder
This commit is contained in:
@@ -156,13 +156,22 @@ async function checkWorkflow(
|
|||||||
await exec("git", ["checkout", "ghes"]);
|
await exec("git", ["checkout", "ghes"]);
|
||||||
|
|
||||||
// In order to sync from main, we might need to remove some workflows, add some
|
// In order to sync from main, we might need to remove some workflows, add some
|
||||||
// and modify others. The lazy approach is to delete all workflows first, and then
|
// and modify others. The lazy approach is to delete all workflows first (except from read-only folders), and then
|
||||||
// just bring the compatible ones over from the main branch. We let git figure out
|
// just bring the compatible ones over from the main branch. We let git figure out
|
||||||
// whether it's a deletion, add, or modify and commit the new state.
|
// whether it's a deletion, add, or modify and commit the new state.
|
||||||
console.log("Remove all workflows");
|
console.log("Remove all workflows");
|
||||||
await exec("rm", ["-fr", ...settings.folders]);
|
await exec("rm", ["-fr", ...settings.folders]);
|
||||||
await exec("rm", ["-fr", "../../icons"]);
|
await exec("rm", ["-fr", "../../icons"]);
|
||||||
|
|
||||||
|
// Bring back the read-only folders
|
||||||
|
console.log("Restore read-only folders");
|
||||||
|
for (let i = 0; i < settings.readOnlyFolders.length; i++) {
|
||||||
|
await exec("git", [
|
||||||
|
"checkout",
|
||||||
|
settings.readOnlyFolders[i]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
console.log("Sync changes from main for compatible workflows");
|
console.log("Sync changes from main for compatible workflows");
|
||||||
await exec("git", [
|
await exec("git", [
|
||||||
"checkout",
|
"checkout",
|
||||||
@@ -171,10 +180,13 @@ async function checkWorkflow(
|
|||||||
...Array.prototype.concat.apply(
|
...Array.prototype.concat.apply(
|
||||||
[],
|
[],
|
||||||
result.compatibleWorkflows.map((x) => {
|
result.compatibleWorkflows.map((x) => {
|
||||||
const r = [
|
const r = [];
|
||||||
join(x.folder, `${x.id}.yml`),
|
|
||||||
join(x.folder, "properties", `${x.id}.properties.json`),
|
// Don't touch read-only folders
|
||||||
];
|
if (!settings.readOnlyFolders.includes(x.folder)) {
|
||||||
|
r.push(join(x.folder, `${x.id}.yml`));
|
||||||
|
r.push(join(x.folder, "properties", `${x.id}.properties.json`));
|
||||||
|
};
|
||||||
|
|
||||||
if (x.iconType === "svg") {
|
if (x.iconType === "svg") {
|
||||||
r.push(join("../../icons", `${x.iconName}.svg`));
|
r.push(join("../../icons", `${x.iconName}.svg`));
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
"folders": [
|
"folders": [
|
||||||
"../../ci",
|
"../../ci",
|
||||||
"../../automation",
|
"../../automation",
|
||||||
"../../code-scanning"
|
"../../code-scanning",
|
||||||
|
"../../pages"
|
||||||
|
],
|
||||||
|
"readOnlyFolders": [
|
||||||
|
"../../pages"
|
||||||
],
|
],
|
||||||
"enabledActions": [
|
"enabledActions": [
|
||||||
"actions/cache",
|
"actions/cache",
|
||||||
|
|||||||
Reference in New Issue
Block a user