Skip to content

Commit 4615530

Browse files
committed
feat: tag docker image
Signed-off-by: james <open4pd@4paradigm.com>
1 parent 5a6e55b commit 4615530

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

.github/workflows/go.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,20 @@ jobs:
4848
with:
4949
driver-opts: image=moby/buildkit:master
5050

51+
- name: Extract tag name
52+
id: tag
53+
run: |
54+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
55+
TAG_NAME="${GITHUB_REF#refs/tags/}"
56+
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
57+
echo "Extracted tag: ${TAG_NAME}"
58+
else
59+
echo "tag_name=latest" >> $GITHUB_OUTPUT
60+
fi
61+
5162
- name: Build and optionally push
5263
uses: docker/build-push-action@v6.18.0
5364
with:
5465
platforms: linux/amd64,linux/arm64
55-
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
56-
tags: projecthami/mock-device-plugin:latest
66+
push: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') }}
67+
tags: projecthami/mock-device-plugin:${{ steps.tag.outputs.tag_name }}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM golang:1.21-bullseye AS GOBUILD
1+
FROM golang:1.21-bullseye AS gobuild
22
ADD . /device-plugin
33
RUN cd /device-plugin && go build -o ./k8s-device-plugin cmd/k8s-device-plugin/main.go
44

55
FROM ubuntu:20.04
66
WORKDIR /root/
7-
COPY --from=GOBUILD /device-plugin/k8s-device-plugin .
7+
COPY --from=gobuild /device-plugin/k8s-device-plugin .
88
CMD ["./k8s-device-plugin", "-logtostderr=true", "-stderrthreshold=INFO", "-v=5", "--device-config-file=/device-config.yaml"]

0 commit comments

Comments
 (0)