36 lines
1.1 KiB
YAML
36 lines
1.1 KiB
YAML
name: Cleanup old test branches
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 12 * * *"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
cleanup_branch:
|
|
runs-on: windows
|
|
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Delete test branches older than 7 days
|
|
shell: powershell
|
|
run: |
|
|
# Obtener la fecha límite (7 días antes)
|
|
$limitDate = (Get-Date).AddDays(-7)
|
|
|
|
# Obtener todas las ramas remotas test/*
|
|
$branches = git branch -r | Where-Object { $_ -match 'origin/test/' }
|
|
|
|
foreach ($branch in $branches) {
|
|
$branchName = $branch.Trim() -replace '^origin/', ''
|
|
# Obtener fecha de creación de la rama (aproximación por el primer commit)
|
|
$firstCommitDate = git log $branchName --reverse --format="%ci" | Select-Object -First 1
|
|
$branchDate = Get-Date $firstCommitDate
|
|
|
|
if ($branchDate -lt $limitDate) {
|
|
Write-Host "Eliminando rama $branchName creada el $branchDate"
|
|
git push origin --delete $branchName
|
|
}
|
|
}
|