Skip to content

Commit

Permalink
CI: Support branches for image tags
Browse files Browse the repository at this point in the history
This allows you to create a branch like `tag/23.10` which will
deploy the image with the tag `23.10`.
  • Loading branch information
TingPing committed Mar 6, 2024
1 parent 5c7d2d9 commit 40aa254
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/wkdev-sdk.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: wkdev-sdk
on:
push:
branches: [ main ]
branches: [ main, tag/** ]
paths-ignore: [ docs/*, README.md]
pull_request:
branches: [ main, tag/** ]
paths-ignore: [ docs/*, README.md]
defaults:
run:
Expand All @@ -16,6 +17,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
Expand Down Expand Up @@ -68,12 +71,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
Expand Down

0 comments on commit 40aa254

Please sign in to comment.