Skip to content

Commit 5f6aa0a

Browse files
committed
fix-push-image-to-registry
1 parent 6ad0fac commit 5f6aa0a

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

.github/workflows/pull_request.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ jobs:
1515
go: ['1.17']
1616

1717
steps:
18-
- name: Install make
18+
- name: install make
1919
run: sudo apt-get install make
20-
- name: Set up Go 1.x
20+
- name: set up go 1.x
2121
uses: actions/setup-go@v2
2222
with:
2323
go-version: ${{ matrix.go }}
24-
id: go
25-
- uses: actions/checkout@v2
26-
27-
- name: Run build
24+
- name: checkout
25+
uses: actions/checkout@v2
26+
- name: run build
2827
run: make build
29-
30-
- name: Run test
28+
- name: run test
3129
run: make test

.github/workflows/push_image.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
name: push image to Quay.io
1+
name: Push image to quay.io
22
on:
33
push:
4+
branches: [ main ]
45

56
env:
67
REGISTRY_USER: netobserv+github_ci
78
REGISTRY_PASSWORD: ${{ secrets.QUAY_SECRET }}
9+
IMAGE: quay.io/netobserv/flowlogs2metrics
10+
TAG: latest
811

912
jobs:
1013
push-image:
@@ -14,19 +17,28 @@ jobs:
1417
matrix:
1518
go: ['1.17']
1619
steps:
17-
- name: podman login to Quay.io
20+
- name: install make
21+
run: sudo apt-get install make
22+
- name: set up go 1.x
23+
uses: actions/setup-go@v2
24+
with:
25+
go-version: ${{ matrix.go }}
26+
- name: checkout
27+
uses: actions/checkout@v2
28+
- name: build image
29+
run: make build-image
30+
- name: podman login to quay.io
1831
uses: redhat-actions/podman-login@v1
1932
with:
2033
username: ${{ env.REGISTRY_USER }}
2134
password: ${{ env.REGISTRY_PASSWORD }}
2235
registry: quay.io
23-
- name: Install make
24-
run: sudo apt-get install make
25-
- name: Set up Go 1.x
26-
uses: actions/setup-go@v2
36+
- name: push to quay.io
37+
id: push-to-quay
38+
uses: redhat-actions/push-to-registry@v2
2739
with:
28-
go-version: ${{ matrix.go }}
29-
id: go
30-
- uses: actions/checkout@v2
31-
- name: push image
32-
run: make push-image
40+
image: ${{ env.IMAGE }}
41+
tags: ${{ env.TAG }}
42+
registry: quay.io/quay-user
43+
- name: print image url
44+
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,14 @@ run: build ## Run
9797

9898
##@ Docker
9999

100-
# note: to push custom image tag use: DOCKER_TAG=test make push-image
100+
# note: to build and push custom image tag use: DOCKER_TAG=test make push-image
101+
.PHONY: build-image
102+
build-image:
103+
DOCKER_BUILDKIT=1 $(OCI_RUNTIME) build -t $(DOCKER_IMG):$(DOCKER_TAG) -f contrib/docker/Dockerfile .
104+
101105
.PHONY: push-image
102-
push-image: ## Push latest image
106+
push-image: build-image ## Push latest image
103107
@echo 'publish image $(DOCKER_TAG) to $(DOCKER_IMG)'
104-
DOCKER_BUILDKIT=1 $(OCI_RUNTIME) build -t $(DOCKER_IMG):$(DOCKER_TAG) -f contrib/docker/Dockerfile .
105108
DOCKER_BUILDKIT=1 $(OCI_RUNTIME) push $(DOCKER_IMG):$(DOCKER_TAG)
106109

107110
##@ kubernetes

0 commit comments

Comments
 (0)