Skip to content

Commit bda02ff

Browse files
Refactor cleanrepo workflow for folder cleanup
1 parent 94fcfd7 commit bda02ff

File tree

1 file changed

+48
-34
lines changed

1 file changed

+48
-34
lines changed

.github/workflows/cleanrepo.yml

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,57 @@ jobs:
2727
- name: Create and switch to new branch
2828
id: create_branch
2929
run: |
30-
DATE=$(date +'%Y%m%d-%H%M')
31-
BRANCH_NAME="cleanrepo-defender-${DATE}"
30+
BRANCH_NAME="cleanrepo-all-$(date +'%Y%m%d-%H%M')"
3231
git checkout -b "$BRANCH_NAME"
3332
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
34-
echo "date=$DATE" >> $GITHUB_ENV
3533
36-
- name: Install Clean Repo CLI
37-
run: npm install -g @microsoft/clean-repo
34+
- name: Clean orphaned content in all folders
35+
uses: actions/github-script@v6
36+
with:
37+
script: |
38+
const folders = [
39+
"ATADocs",
40+
"ATADocs/DeployUse",
41+
"ATADocs/PlanDesign",
42+
"ATADocs/Understand",
43+
"ATADocs/Troubleshoot",
44+
"ATPDocs",
45+
"defender",
46+
"defender-xdr",
47+
"defender-for-iot",
48+
"defender-business",
49+
"defender-endpoint",
50+
"defender-for-cloud",
51+
"defender-office-365",
52+
"exposure-management",
53+
"CloudAppSecurityDocs",
54+
"unified-secops-platform",
55+
"defender-vulnerability-management"
56+
];
3857
39-
- name: Run Clean Repo on all folders
40-
run: |
41-
folders=(
42-
"ATADocs"
43-
"ATADocs/DeployUse"
44-
"ATADocs/PlanDesign"
45-
"ATADocs/Understand"
46-
"ATADocs/Troubleshoot"
47-
"ATPDocs"
48-
"defender"
49-
"defender-xdr"
50-
"defender-for-iot"
51-
"defender-business"
52-
"defender-endpoint"
53-
"defender-for-cloud"
54-
"defender-office-365"
55-
"exposure-management"
56-
"CloudAppSecurityDocs"
57-
"unified-secops-platform"
58-
"defender-vulnerability-management"
59-
)
58+
const functions = [
59+
"FindOrphanedArticles",
60+
"FindOrphanedImages",
61+
"FindOrphanedIncludes",
62+
"FindOrphanedSnippets"
63+
];
64+
65+
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 }}']);
6071
61-
for folder in "${folders[@]}"; do
62-
echo "Cleaning $folder"
63-
cleanrepo --function FindOrphanedArticles --docfx_directory="$folder" --target_directory="$folder" --url_base_path="/dotnet"
64-
cleanrepo --function FindOrphanedImages --docfx_directory="$folder" --target_directory="$folder" --url_base_path="/dotnet"
65-
cleanrepo --function FindOrphanedIncludes --docfx_directory="$folder" --target_directory="$folder" --url_base_path="/dotnet"
66-
cleanrepo --function FindOrphanedSnippets --docfx_directory="$folder" --target_directory="$folder" --url_base_path="/dotnet"
67-
done
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+
}
80+
}
6881
6982
- name: Commit and push changes
7083
run: |
@@ -76,7 +89,7 @@ jobs:
7689
uses: dotnet/actions-create-pull-request@v4
7790
with:
7891
branch: ${{ steps.create_branch.outputs.branch_name }}
79-
title: "Clean Repo Defender: Sep 2025 - ${{ env.date }}"
92+
title: "Clean Repo: Monthly cleanup across all folders"
8093
commit-message: "Automated cleanup for all folders"
8194
body: |
8295
This PR was generated by the Clean Repo GitHub Action.
@@ -94,3 +107,4 @@ jobs:
94107
- unified-secops-platform
95108
- defender-vulnerability-management
96109
110+
Please review before merging.

0 commit comments

Comments
 (0)