Skip to content

Commit

Permalink
Add workflow for cleaning up temporary folders on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
prasadhonrao committed Dec 5, 2024
1 parent 16fd3b9 commit d3aab5b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/misc-temp-folder-cleanup.yml
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."

0 comments on commit d3aab5b

Please sign in to comment.