From 0379065ce862932f461b70acacf9341c46f0ee5a Mon Sep 17 00:00:00 2001 From: richarddushime Date: Mon, 22 Dec 2025 16:26:23 +0100 Subject: [PATCH 01/10] Workflow to Cleanup Branches --- .github/workflows/cleanup-branches.yml | 149 +++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 .github/workflows/cleanup-branches.yml diff --git a/.github/workflows/cleanup-branches.yml b/.github/workflows/cleanup-branches.yml new file mode 100644 index 00000000000..536a13f3849 --- /dev/null +++ b/.github/workflows/cleanup-branches.yml @@ -0,0 +1,149 @@ +name: Cleanup Branches + +on: + schedule: + - cron: '0 0 * * 0' # Run every Sunday at midnight + workflow_dispatch: + inputs: + dry_run: + description: 'Dry run (do not delete)' + required: false + type: boolean + default: false + +permissions: + contents: write + +jobs: + cleanup-staging: + name: Cleanup Staging Aggregate Branches + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Delete old staging branches + env: + DRY_RUN: ${{ inputs.dry_run }} + run: | + echo "Fetching all branches..." + git fetch --all --prune + + echo "Listing staging-aggregate branches..." + # Get branches matching pattern, sort by committer date (descending), skip first 10 + BRANCHES_TO_DELETE=$(git branch -r --list 'origin/staging-aggregate-*' --sort=-committerdate | tail -n +11 | sed 's/origin\///') + + if [ -z "$BRANCHES_TO_DELETE" ]; then + echo "No old staging branches to delete." + exit 0 + fi + + echo "Found branches to delete:" + echo "$BRANCHES_TO_DELETE" + + for branch in $BRANCHES_TO_DELETE; do + branch=$(echo "$branch" | xargs) # trim whitespace + if [ "$DRY_RUN" = "true" ]; then + echo "[DRY RUN] Would delete: $branch" + else + echo "Deleting: $branch" + git push origin --delete "$branch" || echo "Failed to delete $branch" + fi + done + + cleanup-merged: + name: Cleanup Merged Branches + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Delete merged branches + env: + DRY_RUN: ${{ inputs.dry_run }} + run: | + echo "Fetching all branches..." + git fetch --all --prune --tags + + # Define protected branches + PROTECTED_BRANCHES="master|main|staging|production|gh-pages" + + echo "Finding merged branches..." + # List remote branches merged into origin/master, exclude protected ones + MERGED_BRANCHES=$(git branch -r --merged origin/master | grep -vE "HEAD|$PROTECTED_BRANCHES" | sed 's/origin\///') + + if [ -z "$MERGED_BRANCHES" ]; then + echo "No merged branches to delete." + exit 0 + fi + + echo "Found merged branches to delete:" + echo "$MERGED_BRANCHES" + + for branch in $MERGED_BRANCHES; do + branch=$(echo "$branch" | xargs) + if [ "$DRY_RUN" = "true" ]; then + echo "[DRY RUN] Would delete: $branch" + else + echo "Deleting: $branch" + git push origin --delete "$branch" || echo "Failed to delete $branch" + fi + done + + cleanup-stale: + name: Cleanup Stale Branches + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Delete stale branches + env: + DRY_RUN: ${{ inputs.dry_run }} + MONTHS_THRESHOLD: 6 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "Fetching all branches..." + git fetch --all --prune + + PROTECTED_BRANCHES="master|main|staging|production|gh-pages" + + # Calculate threshold date (6 months ago) + THRESHOLD_DATE=$(date -d "-$MONTHS_THRESHOLD months" +%s) + echo "Threshold date: $(date -d "@$THRESHOLD_DATE")" + + echo "Checking for stale branches..." + + # Iterate over all remote branches + git branch -r | grep -vE "HEAD|$PROTECTED_BRANCHES" | while read -r branch; do + branch=$(echo "$branch" | xargs) # trim whitespace + clean_branch_name=${branch#origin/} + + # Get last commit date for the branch + last_commit_date=$(git log -1 --format=%ct "$branch") + + # check if branch has open PR + open_pr_count=$(gh pr list -H "$clean_branch_name" --state open --json number | jq '. | length') + + if [ "$open_pr_count" -gt 0 ]; then + echo "Skipping $clean_branch_name (Has open PR)" + continue + fi + + if [ "$last_commit_date" -lt "$THRESHOLD_DATE" ]; then + echo "Branch '$clean_branch_name' is stale (Last commit: $(date -d "@$last_commit_date"))" + + if [ "$DRY_RUN" = "true" ]; then + echo "[DRY RUN] Would delete: $clean_branch_name" + else + echo "Deleting: $clean_branch_name" + git push origin --delete "$clean_branch_name" || echo "Failed to delete $clean_branch_name" + fi + fi + done From ccb4a948429503bdcb7cf468313972f57a4074e1 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Wed, 21 Jan 2026 16:33:18 +0000 Subject: [PATCH 02/10] Update .github/workflows/cleanup-branches.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/cleanup-branches.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cleanup-branches.yml b/.github/workflows/cleanup-branches.yml index 536a13f3849..59ea029128f 100644 --- a/.github/workflows/cleanup-branches.yml +++ b/.github/workflows/cleanup-branches.yml @@ -13,6 +13,7 @@ on: permissions: contents: write + pull-requests: read jobs: cleanup-staging: From 6b9d407bb81f80201fced76e330bf7b06dbe10a6 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Wed, 21 Jan 2026 16:33:47 +0000 Subject: [PATCH 03/10] Update .github/workflows/cleanup-branches.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/cleanup-branches.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup-branches.yml b/.github/workflows/cleanup-branches.yml index 59ea029128f..d4cac3c8fce 100644 --- a/.github/workflows/cleanup-branches.yml +++ b/.github/workflows/cleanup-branches.yml @@ -129,7 +129,7 @@ jobs: # Get last commit date for the branch last_commit_date=$(git log -1 --format=%ct "$branch") - # check if branch has open PR + # Check if branch has open PR open_pr_count=$(gh pr list -H "$clean_branch_name" --state open --json number | jq '. | length') if [ "$open_pr_count" -gt 0 ]; then From 6123f8500bfe4ffd65dd221bc3f7157b992a46f7 Mon Sep 17 00:00:00 2001 From: Richard Dushime <45734838+richarddushime@users.noreply.github.com> Date: Wed, 21 Jan 2026 17:39:01 +0100 Subject: [PATCH 04/10] Update .github/workflows/cleanup-branches.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/cleanup-branches.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup-branches.yml b/.github/workflows/cleanup-branches.yml index d4cac3c8fce..5edacdd5799 100644 --- a/.github/workflows/cleanup-branches.yml +++ b/.github/workflows/cleanup-branches.yml @@ -122,7 +122,7 @@ jobs: echo "Checking for stale branches..." # Iterate over all remote branches - git branch -r | grep -vE "HEAD|$PROTECTED_BRANCHES" | while read -r branch; do + git branch -r | grep -vE "HEAD|origin/($PROTECTED_BRANCHES)$" | while read -r branch; do branch=$(echo "$branch" | xargs) # trim whitespace clean_branch_name=${branch#origin/} From ca9891caf098b2a065ee189149ef1c6160f9ee29 Mon Sep 17 00:00:00 2001 From: Richard Dushime <45734838+richarddushime@users.noreply.github.com> Date: Tue, 10 Feb 2026 16:13:26 +0100 Subject: [PATCH 05/10] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/cleanup-branches.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cleanup-branches.yml b/.github/workflows/cleanup-branches.yml index 5edacdd5799..0f1dc2cc267 100644 --- a/.github/workflows/cleanup-branches.yml +++ b/.github/workflows/cleanup-branches.yml @@ -33,8 +33,8 @@ jobs: git fetch --all --prune echo "Listing staging-aggregate branches..." - # Get branches matching pattern, sort by committer date (descending), skip first 10 - BRANCHES_TO_DELETE=$(git branch -r --list 'origin/staging-aggregate-*' --sort=-committerdate | tail -n +11 | sed 's/origin\///') + # Get branches matching pattern, sort by committer date (descending), skip first 5 + BRANCHES_TO_DELETE=$(git branch -r --list 'origin/staging-aggregate-*' --sort=-committerdate | tail -n +6 | sed 's/origin\///') if [ -z "$BRANCHES_TO_DELETE" ]; then echo "No old staging branches to delete." From 7009fc7263606ed5181a6a1e3d9d3bfc53f29222 Mon Sep 17 00:00:00 2001 From: Richard Dushime <45734838+richarddushime@users.noreply.github.com> Date: Tue, 10 Feb 2026 16:13:58 +0100 Subject: [PATCH 06/10] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/cleanup-branches.yml | 38 -------------------------- 1 file changed, 38 deletions(-) diff --git a/.github/workflows/cleanup-branches.yml b/.github/workflows/cleanup-branches.yml index 0f1dc2cc267..adb6edd671b 100644 --- a/.github/workflows/cleanup-branches.yml +++ b/.github/workflows/cleanup-branches.yml @@ -16,44 +16,6 @@ permissions: pull-requests: read jobs: - cleanup-staging: - name: Cleanup Staging Aggregate Branches - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Delete old staging branches - env: - DRY_RUN: ${{ inputs.dry_run }} - run: | - echo "Fetching all branches..." - git fetch --all --prune - - echo "Listing staging-aggregate branches..." - # Get branches matching pattern, sort by committer date (descending), skip first 5 - BRANCHES_TO_DELETE=$(git branch -r --list 'origin/staging-aggregate-*' --sort=-committerdate | tail -n +6 | sed 's/origin\///') - - if [ -z "$BRANCHES_TO_DELETE" ]; then - echo "No old staging branches to delete." - exit 0 - fi - - echo "Found branches to delete:" - echo "$BRANCHES_TO_DELETE" - - for branch in $BRANCHES_TO_DELETE; do - branch=$(echo "$branch" | xargs) # trim whitespace - if [ "$DRY_RUN" = "true" ]; then - echo "[DRY RUN] Would delete: $branch" - else - echo "Deleting: $branch" - git push origin --delete "$branch" || echo "Failed to delete $branch" - fi - done - cleanup-merged: name: Cleanup Merged Branches runs-on: ubuntu-latest From b23817437838faeaaa5d71904f845c4dbf9bf9fa Mon Sep 17 00:00:00 2001 From: Richard Dushime <45734838+richarddushime@users.noreply.github.com> Date: Tue, 10 Feb 2026 16:14:36 +0100 Subject: [PATCH 07/10] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/cleanup-branches.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cleanup-branches.yml b/.github/workflows/cleanup-branches.yml index adb6edd671b..41459331b1d 100644 --- a/.github/workflows/cleanup-branches.yml +++ b/.github/workflows/cleanup-branches.yml @@ -36,8 +36,8 @@ jobs: PROTECTED_BRANCHES="master|main|staging|production|gh-pages" echo "Finding merged branches..." - # List remote branches merged into origin/master, exclude protected ones - MERGED_BRANCHES=$(git branch -r --merged origin/master | grep -vE "HEAD|$PROTECTED_BRANCHES" | sed 's/origin\///') + # List remote branches merged into origin/master, exclude HEAD and fully matching protected branches + MERGED_BRANCHES=$(git branch -r --merged origin/master | grep -vE "HEAD|origin/($PROTECTED_BRANCHES)$" | sed 's/origin\///') if [ -z "$MERGED_BRANCHES" ]; then echo "No merged branches to delete." From c1ab604713a0306a298b6178d1029b377c6a0a20 Mon Sep 17 00:00:00 2001 From: richarddushime Date: Tue, 10 Feb 2026 17:26:50 +0100 Subject: [PATCH 08/10] Automated Branch Cleanup Workflow --- .github/workflows/cleanup-branches.yml | 179 ++++++++++++++++++++--- .github/workflows/deploy.yaml | 8 +- .github/workflows/staging-aggregate.yaml | 6 +- 3 files changed, 162 insertions(+), 31 deletions(-) diff --git a/.github/workflows/cleanup-branches.yml b/.github/workflows/cleanup-branches.yml index 41459331b1d..a15a8d2e3bc 100644 --- a/.github/workflows/cleanup-branches.yml +++ b/.github/workflows/cleanup-branches.yml @@ -1,8 +1,18 @@ name: Cleanup Branches +# ======================= +# Branch Cleanup Workflow +# ======================= +# Purpose: Automatically clean up old and merged branches +# Triggers: Weekly on Sundays or manual dispatch +# Jobs: +# - cleanup-auto-generated: Removes old ga-data-update-* and staging-aggregate-* branches (keeps 2 most recent) +# - cleanup-merged: Removes branches already merged into master +# - cleanup-stale: Removes branches with no activity for 6+ months (no open PRs) + on: schedule: - - cron: '0 0 * * 0' # Run every Sunday at midnight + - cron: '0 0 * * 0' # Run every Sunday at midnight UTC workflow_dispatch: inputs: dry_run: @@ -16,6 +26,66 @@ permissions: pull-requests: read jobs: + cleanup-auto-generated: + name: Cleanup Auto-Generated Branches + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + + - name: Delete old auto-generated branches + env: + DRY_RUN: ${{ inputs.dry_run }} + run: | + echo "## ๐Ÿค– Auto-Generated Branch Cleanup" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + git fetch --all --prune + + # Patterns to clean up with their keep counts + # Format: "pattern:keep_count" + PATTERN_CONFIGS=("ga-data-update-:1" "staging-aggregate-:2") + + for config in "${PATTERN_CONFIGS[@]}"; do + pattern="${config%%:*}" + keep_count="${config##*:}" + + echo "### Pattern: \`$pattern*\` (keeping $keep_count)" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + # Get branches matching pattern, sort by name (timestamp), keep only old ones + BRANCHES_TO_DELETE=$(git branch -r --list "origin/${pattern}*" --sort=-committerdate | tail -n +$((keep_count + 1)) | sed 's/origin\///' | xargs) + + if [ -z "$BRANCHES_TO_DELETE" ]; then + echo "No old \`$pattern*\` branches to delete." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + continue + fi + + for branch in $BRANCHES_TO_DELETE; do + branch=$(echo "$branch" | xargs) + if [ "$DRY_RUN" = "true" ]; then + echo "[DRY RUN] Would delete: $branch" + echo "- ๐Ÿ” \`$branch\` (dry run)" >> $GITHUB_STEP_SUMMARY + else + echo "Deleting: $branch" + if git push origin --delete "$branch" 2>/dev/null; then + echo "- โœ… \`$branch\` deleted" >> $GITHUB_STEP_SUMMARY + else + echo "- โŒ \`$branch\` failed to delete" >> $GITHUB_STEP_SUMMARY + fi + fi + done + echo "" >> $GITHUB_STEP_SUMMARY + done + cleanup-merged: name: Cleanup Merged Branches runs-on: ubuntu-latest @@ -25,37 +95,67 @@ jobs: with: fetch-depth: 0 + - name: Configure Git + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + - name: Delete merged branches env: DRY_RUN: ${{ inputs.dry_run }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | echo "Fetching all branches..." git fetch --all --prune --tags - # Define protected branches + # Define protected branches and patterns to skip PROTECTED_BRANCHES="master|main|staging|production|gh-pages" + # Skip auto-generated branches (handled by cleanup-auto-generated job) + SKIP_PATTERNS="staging-aggregate-|ga-data-update-" echo "Finding merged branches..." - # List remote branches merged into origin/master, exclude HEAD and fully matching protected branches - MERGED_BRANCHES=$(git branch -r --merged origin/master | grep -vE "HEAD|origin/($PROTECTED_BRANCHES)$" | sed 's/origin\///') + # List remote branches merged into origin/master, exclude protected ones + MERGED_BRANCHES=$(git branch -r --merged origin/master | grep -vE "HEAD|origin/($PROTECTED_BRANCHES)$" | sed 's/origin\///' | xargs) if [ -z "$MERGED_BRANCHES" ]; then echo "No merged branches to delete." + echo "## ๐Ÿงน Merged Branch Cleanup" >> $GITHUB_STEP_SUMMARY + echo "No merged branches found to delete." >> $GITHUB_STEP_SUMMARY exit 0 fi - echo "Found merged branches to delete:" - echo "$MERGED_BRANCHES" + echo "## ๐Ÿงน Merged Branch Cleanup" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + DELETED_COUNT=0 + SKIPPED_COUNT=0 for branch in $MERGED_BRANCHES; do branch=$(echo "$branch" | xargs) + + # Skip auto-generated branches (handled separately) + if [[ "$branch" =~ ^(staging-aggregate-|ga-data-update-) ]]; then + echo "Skipping $branch (auto-generated, handled separately)" + ((SKIPPED_COUNT++)) + continue + fi + if [ "$DRY_RUN" = "true" ]; then echo "[DRY RUN] Would delete: $branch" + echo "- ๐Ÿ” \`$branch\` (dry run)" >> $GITHUB_STEP_SUMMARY else echo "Deleting: $branch" - git push origin --delete "$branch" || echo "Failed to delete $branch" + if git push origin --delete "$branch" 2>/dev/null; then + echo "- โœ… \`$branch\` deleted" >> $GITHUB_STEP_SUMMARY + ((DELETED_COUNT++)) + else + echo "- โŒ \`$branch\` failed to delete" >> $GITHUB_STEP_SUMMARY + fi fi done + + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Summary:** Deleted $DELETED_COUNT branches, skipped $SKIPPED_COUNT" >> $GITHUB_STEP_SUMMARY cleanup-stale: name: Cleanup Stale Branches @@ -66,47 +166,78 @@ jobs: with: fetch-depth: 0 + - name: Configure Git + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + - name: Delete stale branches env: DRY_RUN: ${{ inputs.dry_run }} - MONTHS_THRESHOLD: 6 + MONTHS_THRESHOLD: 1 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + # Define protected branches and patterns to skip + PROTECTED_BRANCHES="master|main|staging|production|gh-pages" + echo "Fetching all branches..." - git fetch --all --prune + git fetch --all --prune --tags - PROTECTED_BRANCHES="master|main|staging|production|gh-pages" - # Calculate threshold date (6 months ago) THRESHOLD_DATE=$(date -d "-$MONTHS_THRESHOLD months" +%s) echo "Threshold date: $(date -d "@$THRESHOLD_DATE")" - echo "Checking for stale branches..." - - # Iterate over all remote branches - git branch -r | grep -vE "HEAD|origin/($PROTECTED_BRANCHES)$" | while read -r branch; do - branch=$(echo "$branch" | xargs) # trim whitespace + echo "## ๐Ÿ•ฐ๏ธ Stale Branch Cleanup" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Branches with no commits in $MONTHS_THRESHOLD months and no open PRs." >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + DELETED_COUNT=0 + SKIPPED_COUNT=0 + + # Collect branches into array to avoid subshell issues + mapfile -t BRANCHES < <(git branch -r | grep -vE "HEAD|origin/($PROTECTED_BRANCHES)$" | xargs -n1) + + for branch in "${BRANCHES[@]}"; do + branch=$(echo "$branch" | xargs) clean_branch_name=${branch#origin/} + # Skip auto-generated branches (handled by cleanup-auto-generated job) + if [[ "$clean_branch_name" =~ ^(staging-aggregate-|ga-data-update-) ]]; then + echo "Skipping $clean_branch_name (auto-generated, handled separately)" + continue + fi + # Get last commit date for the branch - last_commit_date=$(git log -1 --format=%ct "$branch") - + last_commit_date=$(git log -1 --format=%ct "$branch" 2>/dev/null || echo "0") + # Check if branch has open PR - open_pr_count=$(gh pr list -H "$clean_branch_name" --state open --json number | jq '. | length') - + open_pr_count=$(gh pr list -H "$clean_branch_name" --state open --json number 2>/dev/null | jq '. | length' || echo "0") + if [ "$open_pr_count" -gt 0 ]; then echo "Skipping $clean_branch_name (Has open PR)" + ((SKIPPED_COUNT++)) continue fi - + if [ "$last_commit_date" -lt "$THRESHOLD_DATE" ]; then - echo "Branch '$clean_branch_name' is stale (Last commit: $(date -d "@$last_commit_date"))" - + LAST_DATE=$(date -d "@$last_commit_date" '+%Y-%m-%d') + echo "Branch '$clean_branch_name' is stale (Last commit: $LAST_DATE)" + if [ "$DRY_RUN" = "true" ]; then echo "[DRY RUN] Would delete: $clean_branch_name" + echo "- ๐Ÿ” \`$clean_branch_name\` (last: $LAST_DATE) - dry run" >> $GITHUB_STEP_SUMMARY else echo "Deleting: $clean_branch_name" - git push origin --delete "$clean_branch_name" || echo "Failed to delete $clean_branch_name" + if git push origin --delete "$clean_branch_name" 2>/dev/null; then + echo "- โœ… \`$clean_branch_name\` deleted (last: $LAST_DATE)" >> $GITHUB_STEP_SUMMARY + ((DELETED_COUNT++)) + else + echo "- โŒ \`$clean_branch_name\` failed to delete" >> $GITHUB_STEP_SUMMARY + fi fi fi done + + echo "" >> $GITHUB_STEP_SUMMARY + echo "**Summary:** Deleted $DELETED_COUNT stale branches, skipped $SKIPPED_COUNT (have open PRs)" >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 62fe8b4668c..e89d72a2835 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -3,9 +3,10 @@ name: deploy # ======================= # FORRT Website Deployment # ======================= -# Purpose: Build and deploy the FORRT Hugo website -# Triggers: Push to master, PRs, manual dispatch, or data updates -# Target: Production deployment +# Purpose: Build and deploy the FORRT Hugo website to production +# Triggers: Push to master, manual dispatch, or data updates +# Target: Production (forrt.org) +# Note: Staging deployments are handled by staging-aggregate.yaml on: push: @@ -35,7 +36,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{ github.event.inputs.pr_number && format('refs/pull/{0}/head', github.event.inputs.pr_number) || github.ref }} fetch-depth: 0 # ======================= diff --git a/.github/workflows/staging-aggregate.yaml b/.github/workflows/staging-aggregate.yaml index fbb289d3423..31d641cfb1d 100644 --- a/.github/workflows/staging-aggregate.yaml +++ b/.github/workflows/staging-aggregate.yaml @@ -168,7 +168,7 @@ jobs: # Push the aggregate branch git push origin "$AGGREGATE_BRANCH" - # Clean up old staging branches, keeping only the 5 most recent + # Clean up old staging branches, keeping only the 2 most recent echo "๐Ÿงน Cleaning up old staging branches..." # Get all staging-aggregate branches sorted by name (which includes timestamp YYYYMMDD-HHMMSS) # Lexicographic sorting works correctly because the timestamp format naturally sorts chronologically @@ -176,7 +176,7 @@ jobs: awk '{print $2}' | \ sed 's|refs/heads/||' | \ sort -r | \ - tail -n +6) + tail -n +3) if [ -n "$OLD_BRANCHES" ]; then echo "Found $(echo "$OLD_BRANCHES" | wc -l) old staging branches to delete" @@ -186,7 +186,7 @@ jobs: done echo "โœ… Cleanup completed" else - echo "No old staging branches to delete (keeping 5 most recent)" + echo "No old staging branches to delete (keeping 2 most recent)" fi echo "branch=$AGGREGATE_BRANCH" >> $GITHUB_OUTPUT From 65a529db0a223484f443fff45f3e68fbf1a8f0b3 Mon Sep 17 00:00:00 2001 From: richarddushime Date: Tue, 10 Feb 2026 17:34:43 +0100 Subject: [PATCH 09/10] rm stale br --- .github/workflows/cleanup-branches.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cleanup-branches.yml b/.github/workflows/cleanup-branches.yml index a15a8d2e3bc..eb5b25160b7 100644 --- a/.github/workflows/cleanup-branches.yml +++ b/.github/workflows/cleanup-branches.yml @@ -8,7 +8,7 @@ name: Cleanup Branches # Jobs: # - cleanup-auto-generated: Removes old ga-data-update-* and staging-aggregate-* branches (keeps 2 most recent) # - cleanup-merged: Removes branches already merged into master -# - cleanup-stale: Removes branches with no activity for 6+ months (no open PRs) +# - cleanup-stale: Removes branches with no activity for 1+ month (no open PRs) on: schedule: @@ -183,7 +183,7 @@ jobs: echo "Fetching all branches..." git fetch --all --prune --tags - # Calculate threshold date (6 months ago) + # Calculate threshold date THRESHOLD_DATE=$(date -d "-$MONTHS_THRESHOLD months" +%s) echo "Threshold date: $(date -d "@$THRESHOLD_DATE")" From b8d241ee0952e7a5584d03e268d39c93f9b16a5c Mon Sep 17 00:00:00 2001 From: richarddushime Date: Tue, 10 Feb 2026 17:53:18 +0100 Subject: [PATCH 10/10] clean protected branches that do not exist like main,prod --- .github/workflows/cleanup-branches.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cleanup-branches.yml b/.github/workflows/cleanup-branches.yml index eb5b25160b7..3700ad6debc 100644 --- a/.github/workflows/cleanup-branches.yml +++ b/.github/workflows/cleanup-branches.yml @@ -108,8 +108,8 @@ jobs: echo "Fetching all branches..." git fetch --all --prune --tags - # Define protected branches and patterns to skip - PROTECTED_BRANCHES="master|main|staging|production|gh-pages" + # Define protected branches + PROTECTED_BRANCHES="master|gh-pages" # Skip auto-generated branches (handled by cleanup-auto-generated job) SKIP_PATTERNS="staging-aggregate-|ga-data-update-" @@ -177,8 +177,8 @@ jobs: MONTHS_THRESHOLD: 1 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - # Define protected branches and patterns to skip - PROTECTED_BRANCHES="master|main|staging|production|gh-pages" + # Define protected branches + PROTECTED_BRANCHES="master|gh-pages" echo "Fetching all branches..." git fetch --all --prune --tags