Skip to content

Commit

Permalink
build: update to support tags
Browse files Browse the repository at this point in the history
  • Loading branch information
medcl committed Nov 13, 2024
1 parent d386d57 commit 3a2d834
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
push:
branches:
- main
- 'v*'
- 'v*' # To trigger for any version branches (e.g., v1.0.0)
tags:
- 'v*' # To trigger for any version tags (e.g., v1.0.0)

jobs:
build-deploy-docs:
Expand All @@ -16,22 +18,22 @@ jobs:
with:
fetch-depth: 0

- name: Set Variables Based on Branch
- name: Set Variables Based on Branch or Tag
id: vars
run: |
CURRENT_BRANCH=${GITHUB_REF##*/}
if [[ "$CURRENT_BRANCH" == "main" ]]; then
CURRENT_REF=${GITHUB_REF##*/}
# Check if the trigger is a tag or a branch
if [[ "$CURRENT_REF" == "main" ]]; then
echo "VERSION=latest" >> $GITHUB_ENV
echo "BRANCH=main" >> $GITHUB_ENV
echo "VERSIONS=latest,`git branch -r --list "origin/v*" | sed 's|origin/||' | sort -Vr | tr '\n' ',' | sed 's/,$//'`" >> $GITHUB_ENV
elif [[ "$CURRENT_BRANCH" =~ ^v.* ]]; then
echo "VERSION=$CURRENT_BRANCH" >> $GITHUB_ENV
echo "BRANCH=$CURRENT_BRANCH" >> $GITHUB_ENV
# Create VERSIONS with "latest" and current VERSION, separated by commas
#echo "VERSIONS=latest,$CURRENT_BRANCH" >> $GITHUB_ENV
elif [[ "$CURRENT_REF" =~ ^v.* ]]; then
echo "VERSION=$CURRENT_REF" >> $GITHUB_ENV
echo "BRANCH=$CURRENT_REF" >> $GITHUB_ENV
echo "VERSIONS=latest,`git branch -r --list "origin/v*" | sed 's|origin/||' | sort -Vr | tr '\n' ',' | sed 's/,$//'`" >> $GITHUB_ENV
else
echo "Skipping docs build, branch doesn't match versioning pattern."
echo "Skipping docs build, branch/tag doesn't match versioning pattern."
exit 0
fi
Expand Down

0 comments on commit 3a2d834

Please sign in to comment.