Skip to content

Commit

Permalink
Build docker image in CI for PRs as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mrueg committed Feb 13, 2025
1 parent 82df3de commit 9487cdc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
39 changes: 35 additions & 4 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Pull Request
on: [pull_request]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
lint:
name: Lint
Expand Down Expand Up @@ -74,13 +78,40 @@ jobs:
name: Docker Tests
needs: [lint]
runs-on: ubuntu-latest

steps:
- name: checkout
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
build-args: |
KONSTRAINT_VER="${{ github.ref_name }}"
platforms: linux/arm/v7,linux/arm64,linux/amd64
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: test create command
run: docker run -v $PWD:/konstraint konstraint create /konstraint/examples
Expand Down
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ fmt: ## Ensures consistent formatting on policy tests.
##@ Releases
#

.PHONY: docker-build
docker-build: ## Builds the docker image. Can optionally pass in a version.
ifeq ($(version),)
docker build -t konstraint:latest .
else
docker build -t konstraint:latest -t konstraint:$(version) --build-arg KONSTRAINT_VER=$(version) .
endif

.PHONY: release
release: ## Builds the binaries for each OS and creates the checksums.
@test $(version)
Expand Down

0 comments on commit 9487cdc

Please sign in to comment.