Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix passing the tag to build-args #50

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -27,6 +27,8 @@ jobs:
push: false
tags: rancher/hardened-k8s-metrics-server:${{ env.TAG }}-amd64
file: Dockerfile
build-args: |
TAG=${{ env.TAG }}

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.21.0
@@ -68,3 +70,5 @@ jobs:
file: Dockerfile
outputs: type=docker
platforms: linux/arm64
build-args: |
TAG=${{ env.TAG }}
10 changes: 10 additions & 0 deletions .github/workflows/image-push.yml
Original file line number Diff line number Diff line change
@@ -2,6 +2,9 @@ on:
release:
types: [published]

env:
GITHUB_ACTION_TAG: ${{ github.ref_name }}

jobs:
push-multiarch:
permissions:
@@ -12,6 +15,11 @@ jobs:
- name: Check out code
uses: actions/checkout@v4

- name: Set the TAG value
id: get-TAG
run: |
echo "$(make -s log | grep TAG)" >> "$GITHUB_ENV"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

@@ -39,3 +47,5 @@ jobs:
tags: rancher/hardened-k8s-metrics-server:${{ github.event.release.tag_name }}
file: Dockerfile
platforms: linux/amd64, linux/arm64
build-args: |
TAG=${{ env.TAG }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ FROM base-builder as metrics-builder
ARG PKG="github.com/kubernetes-incubator/metrics-server"
ARG SRC="github.com/kubernetes-sigs/metrics-server"
ARG TAG=v0.7.1
ARG ARCH
ARG TARGETARCH
RUN git clone --depth=1 https://${SRC}.git $GOPATH/src/${PKG}
WORKDIR $GOPATH/src/${PKG}
RUN git fetch --all --tags --prune
@@ -49,7 +49,7 @@ RUN xx-go --wrap && \
go-build-static.sh -gcflags=-trimpath=${GOPATH}/src -o bin/metrics-server ./cmd/metrics-server
RUN go-assert-static.sh bin/*
RUN xx-verify --static bin/*
RUN if [ "${ARCH}" = "amd64" ]; then \
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
go-assert-boring.sh bin/*; \
fi
RUN install bin/metrics-server /usr/local/bin
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -16,7 +16,11 @@ ORG ?= rancher
# but still refers internally to github.com/kubernetes-incubator/metrics-server packages
PKG ?= github.com/kubernetes-incubator/metrics-server
SRC ?= github.com/kubernetes-sigs/metrics-server
TAG ?= v0.7.1$(BUILD_META)
TAG ?= ${GITHUB_ACTION_TAG}

ifeq ($(TAG),)
TAG := v0.7.1$(BUILD_META)
endif

ifeq (,$(filter %$(BUILD_META),$(TAG)))
$(error TAG $(TAG) needs to end with build metadata: $(BUILD_META))
@@ -48,7 +52,7 @@ image-scan:
PHONY: log
log:
@echo "ARCH=$(ARCH)"
@echo "TAG=$(TAG)"
@echo "TAG=$(TAG:$(BUILD_META)=)"
@echo "ORG=$(ORG)"
@echo "PKG=$(PKG)"
@echo "SRC=$(SRC)"