@@ -28,10 +28,12 @@ jobs:
28
28
id : create_branch
29
29
run : |
30
30
BRANCH_NAME="cleanrepo-all-$(date +'%Y%m%d-%H%M')"
31
+ git checkout main || git checkout -b main
32
+ git pull origin main
31
33
git checkout -b "$BRANCH_NAME"
32
34
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
33
35
34
- - name : Clean orphaned content in all folders
36
+ - name : Run Clean Repo on all folders
35
37
uses : actions/github-script@v6
36
38
with :
37
39
script : |
@@ -55,31 +57,50 @@ jobs:
55
57
"defender-vulnerability-management"
56
58
];
57
59
58
- const functions = [
59
- "FindOrphanedArticles",
60
- "FindOrphanedImages",
61
- "FindOrphanedIncludes",
62
- "FindOrphanedSnippets"
63
- ];
64
-
65
60
for (const folder of folders) {
66
- for (const func of functions) {
67
- await exec.exec('git', ['restore', '--source=HEAD', '--staged', '--worktree', folder]);
68
- await exec.exec('git', ['clean', '-fd', folder]);
69
- await exec.exec('git', ['pull']);
70
- await exec.exec('git', ['checkout', '${{ steps.create_branch.outputs.branch_name }}']);
71
-
72
- await exec.exec('gh', [
73
- 'run', 'dotnet/docs-tools/cleanrepo@main',
74
- '--function', func,
75
- '--docfx_directory', folder,
76
- '--target_directory', folder,
77
- '--url_base_path', '/dotnet'
78
- ]);
79
- }
61
+ core.info(`Cleaning folder: ${folder}`);
62
+
63
+ await exec.exec('git', ['add', folder]);
64
+
65
+ await exec.exec('git', ['commit', '-m', `Clean Repo: ${folder}`]);
66
+
67
+ await exec.exec('git', ['push', 'origin', process.env.BRANCH_NAME]);
68
+
69
+ await exec.exec('gh', [
70
+ 'workflow', 'run',
71
+ 'dotnet/docs-tools/cleanrepo@main',
72
+ '--function', 'FindOrphanedArticles',
73
+ '--docfx_directory', folder,
74
+ '--target_directory', folder,
75
+ '--url_base_path', '/dotnet'
76
+ ]);
77
+ await exec.exec('gh', [
78
+ 'workflow', 'run',
79
+ 'dotnet/docs-tools/cleanrepo@main',
80
+ '--function', 'FindOrphanedImages',
81
+ '--docfx_directory', folder,
82
+ '--target_directory', folder,
83
+ '--url_base_path', '/dotnet'
84
+ ]);
85
+ await exec.exec('gh', [
86
+ 'workflow', 'run',
87
+ 'dotnet/docs-tools/cleanrepo@main',
88
+ '--function', 'FindOrphanedIncludes',
89
+ '--docfx_directory', folder,
90
+ '--target_directory', folder,
91
+ '--url_base_path', '/dotnet'
92
+ ]);
93
+ await exec.exec('gh', [
94
+ 'workflow', 'run',
95
+ 'dotnet/docs-tools/cleanrepo@main',
96
+ '--function', 'FindOrphanedSnippets',
97
+ '--docfx_directory', folder,
98
+ '--target_directory', folder,
99
+ '--url_base_path', '/dotnet'
100
+ ]);
80
101
}
81
102
82
- - name : Commit and push changes
103
+ - name : Commit and push all changes
83
104
run : |
84
105
git add .
85
106
git commit -m "Clean Repo: Automated cleanup across all folders"
0 commit comments