From 8e7997bc9fe60654954f2268605e0f611eaf0612 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Wed, 6 Mar 2024 10:31:35 -0600 Subject: [PATCH] CI: Support branches for image tags This allows you to create a branch like `tag/23.10` which will deploy the image with the tag `23.10`. --- .github/workflows/wkdev-sdk.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wkdev-sdk.yml b/.github/workflows/wkdev-sdk.yml index 0f263f9..7d04a71 100644 --- a/.github/workflows/wkdev-sdk.yml +++ b/.github/workflows/wkdev-sdk.yml @@ -1,7 +1,7 @@ name: wkdev-sdk on: push: - branches: [ main ] + branches: [ main, tag/** ] paths-ignore: [ docs/*, README.md] pull_request: paths-ignore: [ docs/*, README.md] @@ -16,6 +16,8 @@ jobs: run: | if [ "${GITHUB_BASE_REF}" = 'main' ]; then tag_name='latest' + elif [[ "${GITHUB_BASE_REF}" =~ ^tag/(.*)$ ]]; then + tag_name="${BASH_REMATCH[1]}" else tag_name="${GITHUB_BASE_REF}" fi @@ -68,12 +70,14 @@ jobs: deploy: runs-on: ubuntu-22.04 needs: build - if: github.ref_name == 'main' + if: github.ref_name == 'main' || startsWith(github.ref_name, 'tag/') steps: - name: Set tag name run: | if [ "${GITHUB_BASE_REF}" = 'main' ]; then tag_name='latest' + elif [[ "${GITHUB_BASE_REF}" =~ ^tag/(.*)$ ]]; then + tag_name="${BASH_REMATCH[1]}" else tag_name="${GITHUB_BASE_REF}" fi