Skip to content

Commit bd53b29

Browse files
authored
Use most recent release when creating stable branch the first time
Refs #1, #2
1 parent d50b69f commit bd53b29

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

.github/workflows/stable-docs.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,27 @@ jobs:
2222
run: |
2323
git config user.name "Automated"
2424
git config user.email "[email protected]"
25-
2625
- name: Check if stable branch exists
2726
run: |
2827
if ! git ls-remote --heads origin stable | grep stable; then
28+
# Fetch all tags and sort them in descending order
29+
LATEST_RELEASE=$(git tag | sort -Vr | head -n1)
30+
# If no release is found, default to the main branch
31+
if [ -z "$LATEST_RELEASE" ]; then
32+
LATEST_RELEASE="main"
33+
fi
34+
# Check out the latest release or main branch
35+
git checkout $LATEST_RELEASE
2936
git checkout -b stable
3037
git push -u origin stable
3138
fi
32-
3339
- name: Handle Release
3440
if: github.event_name == 'release'
3541
run: |
3642
git fetch --all
3743
git checkout stable
3844
git reset --hard ${GITHUB_REF#refs/tags/}
3945
git push origin stable --force
40-
4146
- name: Handle Commit to Main
4247
if: contains(github.event.head_commit.message, '!stable-docs')
4348
run: |

0 commit comments

Comments
 (0)