Skip to content

Commit e9612c3

Browse files
authored
refactor(ci): replace Makefile-based Docker builds with GitHub Action (#1082)
Signed-off-by: Jesse Amamgbu <amamgbujesse@yahoo.com>
1 parent 688c88f commit e9612c3

File tree

3 files changed

+52
-20
lines changed

3 files changed

+52
-20
lines changed

.github/workflows/pr.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ name: pr
22

33
on: [pull_request]
44

5+
56
permissions: {}
67

8+
env:
9+
IMAGE: openpolicyagent/conftest
10+
PLATFORMS: linux/amd64,linux/arm64
11+
712
jobs:
813
style:
914
runs-on: ubuntu-latest
@@ -60,6 +65,18 @@ jobs:
6065
- name: build
6166
run: make build
6267

68+
- name: setup docker buildx
69+
run: docker buildx create --name conftestbuild --use
70+
71+
- name: Build Docker image
72+
uses: docker/build-push-action@v6
73+
with:
74+
context: .
75+
push: false
76+
tags: |
77+
${{ env.IMAGE }}:latest
78+
platforms: ${{ env.PLATFORMS }}
79+
6380
- name: unit test
6481
run: make test
6582

.github/workflows/release.yaml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
tags:
66
- 'v*'
7+
env:
8+
IMAGE: openpolicyagent/conftest
9+
PLATFORMS: linux/amd64,linux/arm64
710

811
jobs:
912
release:
@@ -36,10 +39,37 @@ jobs:
3639
- name: setup docker buildx
3740
run: docker buildx create --name conftestbuild --use
3841

39-
- name: push images
40-
env:
41-
VERSION: ${{ steps.get-version.outputs.VERSION }}
42-
run: make push TAG=$VERSION
42+
- name: Build and push Docker image
43+
uses: docker/build-push-action@v6
44+
with:
45+
context: .
46+
push: true
47+
build-args: |
48+
VERSION=${{ steps.get-version.outputs.VERSION }}
49+
tags: |
50+
${{ env.IMAGE }}:${{ steps.get-version.outputs.VERSION }}
51+
platforms: ${{ env.PLATFORMS }}
52+
53+
- name: Build and push Docker latest image
54+
uses: docker/build-push-action@v6
55+
with:
56+
context: .
57+
push: true
58+
build-args: |
59+
VERSION=${{ steps.get-version.outputs.VERSION }}
60+
tags: |
61+
${{ env.IMAGE }}:latest
62+
platforms: ${{ env.PLATFORMS }}
63+
64+
- name: Build and push examples image
65+
uses: docker/build-push-action@v6
66+
with:
67+
context: .
68+
push: true
69+
target: examples
70+
tags: |
71+
${{ env.IMAGE }}:examples
72+
platforms: ${{ env.PLATFORMS }}
4373

4474
- name: setup go
4575
uses: actions/setup-go@v4
@@ -52,4 +82,4 @@ jobs:
5282
args: release --clean
5383
version: "~> v1"
5484
env:
55-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Makefile

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,3 @@ help:
6464
#
6565
##@ Releases
6666
#
67-
68-
.PHONY: image
69-
image: ## Builds a Docker image for Conftest.
70-
@$(DOCKER) build . -t $(IMAGE):latest
71-
72-
.PHONY: examples
73-
examples: ## Builds the examples Docker image.
74-
@$(DOCKER) build . --target examples -t $(IMAGE):examples
75-
76-
.PHONY: push
77-
push: ## Pushes the examples and Conftest image to DockerHub. Requires `TAG` parameter.
78-
@test -n "$(TAG)" || (echo "TAG parameter not set." && exit 1)
79-
@$(DOCKER) buildx build . --push --build-arg VERSION="$(TAG)" -t $(IMAGE):$(TAG) --platform $(DOCKER_PLATFORMS)
80-
@$(DOCKER) buildx build . --push --build-arg VERSION="$(TAG)" -t $(IMAGE):latest --platform $(DOCKER_PLATFORMS)
81-
@$(DOCKER) buildx build . --push --target examples -t $(IMAGE):examples --platform $(DOCKER_PLATFORMS)

0 commit comments

Comments
 (0)