From 4ac5f42ad23a29523294f486246af145d51841b4 Mon Sep 17 00:00:00 2001 From: Sun Serega Date: Fri, 26 Apr 2024 12:43:06 +0200 Subject: [PATCH] delete lagacy `gh-pages` branches --- .github/workflows/on commit.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/on commit.yaml b/.github/workflows/on commit.yaml index c66a9e90..c738f884 100644 --- a/.github/workflows/on commit.yaml +++ b/.github/workflows/on commit.yaml @@ -27,6 +27,18 @@ jobs: git config --global user.name "sun pack bot" git config --global user.email "sunserega2@gmail.com" git config --global --add url.https://github.com/.insteadOf "git@github.com:" + git fetch origin + + for branch in $(git branch -r | grep 'origin/gh-pages/'); do + branch_name=$(echo $branch | sed 's#origin/gh-pages/##') + echo "Testing legacy branch [$branch]" + + if ! git branch -r | grep -q "origin/$branch_name"; then + echo "Deleting legacy branch [$branch]" + git push origin --delete $(echo $branch | sed 's#origin/##') + fi + + done branch_name="gh-pages/$(git rev-parse --abbrev-ref HEAD)" git checkout --orphan "$branch_name" @@ -35,7 +47,6 @@ jobs: git add . git commit -m "Split off gh-pages" - git fetch origin if git show-ref --verify --quiet refs/remotes/origin/$branch_name; then echo "Remote branch $branch_name found" if [ -z "$( git diff "origin/$branch_name" )" ]; then