Skip to content

Commit ec9ca7a

Browse files
authored
Update workflow, setup workflow-test (#126)
* Update workflow, setup workflow-test - Can trigger workflow from branch workflow-test - Make default multi-arch to single amd64 - Remove specific ci targets; make shortlive builds more straightforward - Disambiguate makefile env vs workflow env - Remove unused targets - Remove now unused shortlived dockerfile * Prefer docker over podman for ci
1 parent 3df4bfe commit ec9ca7a

File tree

7 files changed

+36
-80
lines changed

7 files changed

+36
-80
lines changed

.github/workflows/push_image.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
name: Build and push to quay.io
22
on:
33
push:
4-
branches: [ main ]
4+
branches: [ main, workflow-test ]
55

66
env:
7-
REGISTRY_USER: netobserv+github_ci
8-
REGISTRY: quay.io/netobserv
9-
IMAGE: netobserv-ebpf-agent
10-
ORG: netobserv
11-
VERSION: main
7+
WF_REGISTRY_USER: netobserv+github_ci
8+
WF_ORG: netobserv
9+
WF_MULTIARCH_TARGETS: amd64 arm64 ppc64le
10+
WF_VERSION: ${{ github.ref_name }}
1211

1312
jobs:
1413
push-image:
@@ -29,10 +28,12 @@ jobs:
2928
- name: docker login to quay.io
3029
uses: docker/login-action@v2
3130
with:
32-
username: ${{ env.REGISTRY_USER }}
31+
username: ${{ env.WF_REGISTRY_USER }}
3332
password: ${{ secrets.QUAY_SECRET }}
3433
registry: quay.io
34+
- name: get short sha
35+
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
3536
- name: build and push manifest with images
36-
run: IMAGE_ORG=${{ env.ORG }} VERSION=${{ env.VERSION }} make ci
37-
- name: print image url
38-
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
37+
run: |
38+
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.WF_VERSION }} make images
39+
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.short_sha }} OCI_BUILD_OPTS="--label quay.expires-after=2w" make images

.github/workflows/push_image_pr.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ on:
44
types: [labeled]
55

66
env:
7-
REGISTRY_USER: netobserv+github_ci
8-
REGISTRY: quay.io/netobserv
9-
IMAGE: netobserv-ebpf-agent
10-
ORG: netobserv
7+
WF_REGISTRY_USER: netobserv+github_ci
8+
WF_REGISTRY: quay.io/netobserv
9+
WF_IMAGE: netobserv-ebpf-agent
10+
WF_ORG: netobserv
1111

1212
jobs:
1313
push-pr-image:
@@ -31,15 +31,13 @@ jobs:
3131
- name: docker login to quay.io
3232
uses: docker/login-action@v2
3333
with:
34-
username: ${{ env.REGISTRY_USER }}
34+
username: ${{ env.WF_REGISTRY_USER }}
3535
password: ${{ secrets.QUAY_SECRET }}
3636
registry: quay.io
3737
- name: get short sha
3838
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
39-
- name: build and push images
40-
run: IMAGE_ORG=${{ env.ORG }} IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ env.short_sha }} make images
41-
- name: build and push manifest
42-
run: IMAGE_ORG=${{ env.ORG }} IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ env.short_sha }} make ci-manifest
39+
- name: build and push manifest with images
40+
run: OCI_BUILD_OPTS="--label quay.expires-after=2w" IMAGE_ORG=${{ env.WF_ORG }} IMAGE=${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.short_sha }} make images
4341
- uses: actions/github-script@v6
4442
with:
4543
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -48,5 +46,5 @@ jobs:
4846
issue_number: context.issue.number,
4947
owner: context.repo.owner,
5048
repo: context.repo.repo,
51-
body: 'New image: ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ env.short_sha }}. It will expire after two weeks.'
49+
body: 'New image: ${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.short_sha }}. It will expire after two weeks.'
5250
})

.github/workflows/release.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ on:
44
tags: [v*]
55

66
env:
7-
REGISTRY_USER: netobserv+github_ci
8-
REGISTRY_PASSWORD: ${{ secrets.QUAY_SECRET }}
9-
REGISTRY: quay.io/netobserv
10-
IMAGE: netobserv-ebpf-agent
11-
IMAGE_ORG: netobserv
7+
WF_REGISTRY_USER: netobserv+github_ci
8+
WF_ORG: netobserv
9+
WF_MULTIARCH_TARGETS: amd64 arm64 ppc64le
1210

1311
jobs:
1412
push-image:
1513
name: push image
16-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-latest
1715
strategy:
1816
matrix:
1917
go: ['1.19']
@@ -40,10 +38,8 @@ jobs:
4038
- name: docker login to quay.io
4139
uses: docker/login-action@v2
4240
with:
43-
username: ${{ env.REGISTRY_USER }}
44-
password: ${{ env.REGISTRY_PASSWORD }}
41+
username: ${{ env.WF_REGISTRY_USER }}
42+
password: ${{ secrets.QUAY_SECRET }}
4543
registry: quay.io
46-
- name: build and push images
47-
run: VERSION="${{ env.tag }}" make images
48-
- name: print image url
49-
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
44+
- name: build and push manifest with images
45+
run: MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.tag }} make images

.mk/shortcuts.mk

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,3 @@ push-manifest: manifest-push ## Push MULTIARCH_TARGETS manifest
1717

1818
.PHONY: images
1919
images: image-build image-push manifest-build manifest-push ## Build and push MULTIARCH_TARGETS images and related manifest
20-
21-
.PHONY: build-ci-manifest
22-
build-ci-manifest: ci-manifest-build ## Build CI manifest
23-
24-
.PHONY: push-ci-manifest
25-
push-ci-manifest: ci-manifest-push ## Push CI manifest
26-
27-
.PHONY: ci-manifest
28-
ci-manifest: ci-manifest-build ci-manifest-push ## Build and push CI manifest
29-
30-
.PHONY: ci
31-
ci: images ci-manifest ## Build and push CI images and manifest

Makefile

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ endif
1818

1919
# Go architecture and targets images to build
2020
GOARCH ?= amd64
21-
MULTIARCH_TARGETS ?= amd64 arm64 ppc64le
21+
MULTIARCH_TARGETS ?= amd64
2222

2323
# In CI, to be replaced by `netobserv`
2424
IMAGE_ORG ?= $(USER)
@@ -28,10 +28,10 @@ IMAGE_TAG_BASE ?= quay.io/$(IMAGE_ORG)/netobserv-ebpf-agent
2828

2929
# Image URL to use all building/pushing image targets
3030
IMAGE ?= $(IMAGE_TAG_BASE):$(VERSION)
31-
IMAGE_SHA = $(IMAGE_TAG_BASE):$(BUILD_SHA)
31+
OCI_BUILD_OPTS ?=
3232

33-
# Image building tool (docker / podman)
34-
OCI_BIN_PATH := $(shell which podman || which docker)
33+
# Image building tool (docker / podman) - docker is preferred in CI
34+
OCI_BIN_PATH := $(shell which docker || which podman)
3535
OCI_BIN ?= $(shell basename ${OCI_BIN_PATH})
3636

3737
LOCAL_GENERATOR_IMAGE ?= ebpf-generator:latest
@@ -49,7 +49,7 @@ EXCLUDE_COVERAGE_FILES="(/cmd/)|(bpf_bpfe)|(/examples/)|(/pkg/pbflow/)"
4949
# build a single arch target provided as argument
5050
define build_target
5151
echo 'building image for arch $(1)'; \
52-
DOCKER_BUILDKIT=1 $(OCI_BIN) buildx build --load --build-arg TARGETPLATFORM=linux/$(1) --build-arg TARGETARCH=$(1) --build-arg BUILDPLATFORM=linux/amd64 -t ${IMAGE}-$(1) -f Dockerfile .;
52+
DOCKER_BUILDKIT=1 $(OCI_BIN) buildx build --load --build-arg TARGETPLATFORM=linux/$(1) --build-arg TARGETARCH=$(1) --build-arg BUILDPLATFORM=linux/amd64 ${OCI_BUILD_OPTS} -t ${IMAGE}-$(1) -f Dockerfile .;
5353
endef
5454

5555
# push a single arch target image
@@ -59,9 +59,9 @@ define push_target
5959
endef
6060

6161
# manifest create a single arch target provided as argument
62-
define manifest_create_target
63-
echo 'manifest create for arch $(1)'; \
64-
DOCKER_BUILDKIT=1 $(OCI_BIN) manifest add ${IMAGE} ${IMAGE}-$(target);
62+
define manifest_add_target
63+
echo 'manifest add target $(1)'; \
64+
DOCKER_BUILDKIT=1 $(OCI_BIN) manifest add ${IMAGE} ${IMAGE}-$(1);
6565
endef
6666

6767
##@ General
@@ -181,7 +181,7 @@ ifeq (${OCI_BIN}, docker)
181181
else
182182
trap 'exit' INT; \
183183
DOCKER_BUILDKIT=1 $(OCI_BIN) manifest create ${IMAGE} ||:
184-
$(foreach target,$(MULTIARCH_TARGETS),$(call manifest_create_target,$(target)))
184+
$(foreach target,$(MULTIARCH_TARGETS),$(call manifest_add_target,$(target)))
185185
endif
186186

187187
.PHONY: manifest-push
@@ -193,21 +193,4 @@ else
193193
DOCKER_BUILDKIT=1 $(OCI_BIN) manifest push ${IMAGE} docker://${IMAGE};
194194
endif
195195

196-
.PHONY: ci-manifest-build
197-
ci-manifest-build: manifest-build ## Build CI manifest
198-
$(OCI_BIN) build --build-arg BASE_IMAGE=$(IMAGE) -t $(IMAGE_SHA) -f scripts/shortlived.Dockerfile .
199-
ifeq ($(VERSION), main)
200-
# Also tag "latest" only for branch "main"
201-
$(OCI_BIN) build -t $(IMAGE) -t $(IMAGE_TAG_BASE):latest -f scripts/shortlived.Dockerfile .
202-
endif
203-
204-
.PHONY: ci-manifest-push
205-
ci-manifest-push: ## Push CI manifest
206-
$(OCI_BIN) push $(IMAGE_SHA)
207-
ifeq ($(VERSION), main)
208-
# Also tag "latest" only for branch "main"
209-
$(OCI_BIN) push ${IMAGE}
210-
$(OCI_BIN) push $(IMAGE_TAG_BASE):latest
211-
endif
212-
213196
include .mk/shortcuts.mk

scripts/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,3 @@ to run this script unless you want to e.g. update any of them to a newer version
99

1010
Dockerfile for the eBPF binaries and Protobuf implementation generator. It is invoked from the root
1111
`Makefile`, in the `make docker-generate` target.
12-
13-
## `shortlived.Dockerfile`
14-
15-
Dockerfile to generate a short-lived image of the agent that corresponds to the commits in the
16-
`main` branch of the project Git.
17-
18-
The published images expire after 2 weeks.

scripts/shortlived.Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)