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: agent version used in build so gha properly evaluates env var #201

Closed
wants to merge 14 commits into from
Closed
14 changes: 12 additions & 2 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.9.0

- name: Determine build release version
id: get_version
run: |
git fetch --tags
echo "RELEASE_VERSION is currently: ${RELEASE_VERSION}"
version=$(git describe --always --match "v[0-9]*")
echo "I'm going to set it to: ${version}"
echo "RELEASE_VERSION=${version}" >> "$GITHUB_ENV"

- name: Build docker image
uses: docker/build-push-action@v4.1.1
with:
context: .
build-args: |
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
push: false
platforms: linux/amd64
# platforms: linux/amd64,linux/arm64 - don't build arm64 on PRs for now
cache-from: type=gha
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This disables docker layer caching between builds - does this prevent git tags being detected correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this doesn't seem to be related to our issue. Was just trying different settings to try to determine why the tag wasn't rendering as expected. I've set this PR back to draft as we'll be putting it down for now after removing the build interpreting version in #206

cache-to: type=gha,mode=max

6 changes: 6 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ jobs:
with:
images: ghcr.io/honeycombio/network-agent

- name: Determine build release version
id: get_version
run: echo "RELEASE_VERSION=$(make version)" >> "$GITHUB_ENV"

- name: Build and push
uses: docker/build-push-action@v4.1.1
with:
context: .
push: true
build-args: |
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ WORKDIR /src
COPY go.* .
RUN go mod download
COPY . .
ARG RELEASE_VERSION
RUN make build

FROM ubuntu:22.04
RUN apt-get update -yq && apt-get install -yq ca-certificates libpcap-dev
COPY --from=builder /src/hny-network-agent /bin/hny-network-agent
ENTRYPOINT [ "/bin/hny-network-agent" ]
ENTRYPOINT [ "/bin/hny-network-agent" ]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ build:
.PHONY: docker-build
#: build the agent image
docker-build:
docker build --tag $(IMG_NAME):$(IMG_TAG) .
docker build --tag $(IMG_NAME):$(IMG_TAG) --build-arg="RELEASE_VERSION=$(RELEASE_VERSION)" .

.PHONY: update-headers
#: retrieve libbpf headers
Expand Down
Loading