Skip to content

Commit 6de0c9d

Browse files
committed
ci/cd: 修改Docker构建流程以支持从Git分支提取版本
1 parent 4985460 commit 6de0c9d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

.github/workflows/docker-image.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ jobs:
1616
with:
1717
username: ${{ secrets.DOCKERHUB_USERNAME }}
1818
password: ${{ secrets.DOCKERHUB_TOKEN }}
19-
- name: Extract version from Git tag
19+
- name: Extract version from Git ref
2020
id: vars
21-
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
21+
run: |
22+
if [[ $GITHUB_REF == refs/tags/* ]]; then
23+
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
24+
else
25+
echo "VERSION=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
26+
fi
2227
- name: Set up Docker Buildx
2328
uses: docker/setup-buildx-action@v3
2429
- name: Build and push

0 commit comments

Comments
 (0)