Skip to content

Commit 09ef7b1

Browse files
Update mirror_repo.yml
1 parent 29dc98f commit 09ef7b1

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

.github/workflows/mirror_repo.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,19 @@ jobs:
6767
6868
# Ensure required branches exist in the mirror
6969
for required_branch in "${REQUIRED_BRANCHES[@]}"; do
70-
if ! git ls-remote --exit-code --heads mirror $required_branch &>/dev/null; then
71-
echo "Branch $required_branch is missing in the mirror. Creating it."
72-
git checkout --orphan $required_branch
73-
git rm -rf .
74-
echo "This branch is a placeholder for $required_branch." > README.md
75-
git add README.md
76-
git commit -m "Create placeholder for $required_branch"
77-
git push mirror $required_branch:$required_branch --force
78-
else
79-
echo "Branch $required_branch already exists in the mirror."
70+
# Check if the branch already exists locally or remotely in the mirror
71+
if git branch --list $required_branch || git ls-remote --exit-code --heads mirror $required_branch &>/dev/null; then
72+
echo "Branch $required_branch already exists. Skipping creation."
73+
continue
8074
fi
75+
76+
echo "Branch $required_branch is missing in the mirror. Creating it."
77+
git checkout --orphan $required_branch
78+
git rm -rf .
79+
echo "This branch is a placeholder for $required_branch." > README.md
80+
git add README.md
81+
git commit -m "Create placeholder for $required_branch"
82+
git push mirror $required_branch:$required_branch --force
8183
done
8284
env:
8385
GITHUB_TOKEN: ${{ secrets.MIRROR_PAT }}

0 commit comments

Comments
 (0)