From 3a2d834d0666b115fef8fa8d9b7f0f6d10116d24 Mon Sep 17 00:00:00 2001 From: medcl Date: Wed, 13 Nov 2024 11:37:49 +0800 Subject: [PATCH] build: update to support tags --- .github/workflows/build-docs.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 4544e7d0..c9c61164 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -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: @@ -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