-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow for cleaning up temporary folders on Windows
- Loading branch information
1 parent
16fd3b9
commit d3aab5b
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Misc - Temp Folder Cleanup | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: # Allows manual triggering of the workflow | ||
|
||
jobs: | ||
cleanup-temp: | ||
runs-on: self-hosted # Uses the self-hosted runner | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
|
||
# Step 1: Check if the runner is on Windows OS | ||
- name: Check OS | ||
run: | | ||
echo "Running on OS: $RUNNER_OS" | ||
shell: bash | ||
|
||
# Step 2: List all folders in C:\temp (only on Windows, and if C:\temp exists) | ||
- name: List all folders in C:\temp | ||
if: ${{ runner.os == 'Windows' }} && (exists 'C:\temp') | ||
run: | | ||
echo "Listing all folders in C:\temp..." | ||
dir C:\temp /AD /B | ||
# Step 3: Delete all folders in C:\temp | ||
- name: Delete all folders in C:\temp | ||
if: ${{ runner.os == 'Windows' }} && (exists 'C:\temp') | ||
run: | | ||
echo "Deleting all folders in C:\temp..." | ||
# PowerShell command to remove all directories in C:\temp | ||
Get-ChildItem -Path C:\temp -Directory | Remove-Item -Recurse -Force | ||
shell: pwsh | ||
|
||
# Step 4: If C:\temp doesn't exist, log a message and skip | ||
- name: Skip Cleanup if C:\temp doesn't exist | ||
if: ${{ runner.os == 'Windows' }} && !(exists 'C:\temp') | ||
run: | | ||
echo "C:\temp does not exist. Skipping cleanup step." |